From 22fe9a644bd8a19240e11c50778930a2a99216b6 Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Sun, 14 Oct 2018 23:26:01 +0800 Subject: [PATCH] extract auto-generated go api from https://github.com/BitMEX/api-connectors/commit/046f973c6cb078f3e949c747a7e6af3838c69252 --- README.md | 179 +- api/swagger.yaml | 5992 ++++++++++++++++++++++++++++++++ api_announcement.go | 314 ++ api_api_key.go | 864 +++++ api_chat.go | 580 ++++ api_execution.go | 434 +++ api_funding.go | 191 + api_instrument.go | 839 +++++ api_insurance.go | 191 + api_leaderboard.go | 314 ++ api_liquidation.go | 191 + api_notification.go | 185 + api_order.go | 1718 +++++++++ api_order_book.go | 158 + api_position.go | 862 +++++ api_quote.go | 365 ++ api_schema.go | 275 ++ api_settlement.go | 191 + api_stats.go | 383 ++ api_trade.go | 366 ++ api_user.go | 2592 ++++++++++++++ client.go | 519 +++ configuration.go | 73 + docs/APIKeyApi.md | 163 + docs/AccessToken.md | 13 + docs/Affiliate.md | 24 + docs/Announcement.md | 14 + docs/AnnouncementApi.md | 65 + docs/ApiKey.md | 18 + docs/Chat.md | 16 + docs/ChatApi.md | 129 + docs/ChatChannel.md | 11 + docs/ConnectedUsers.md | 11 + docs/ErrorError.md | 11 + docs/Execution.md | 56 + docs/ExecutionApi.md | 92 + docs/Funding.md | 14 + docs/FundingApi.md | 49 + docs/IndexComposite.md | 16 + docs/InlineResponse200.md | 10 + docs/InlineResponse2001.md | 10 + docs/Instrument.md | 110 + docs/InstrumentApi.md | 189 + docs/InstrumentInterval.md | 11 + docs/Insurance.md | 12 + docs/InsuranceApi.md | 49 + docs/Leaderboard.md | 12 + docs/LeaderboardApi.md | 65 + docs/Liquidation.md | 14 + docs/LiquidationApi.md | 49 + docs/Margin.md | 50 + docs/ModelError.md | 10 + docs/Notification.md | 19 + docs/NotificationApi.md | 33 + docs/Order.md | 42 + docs/OrderApi.md | 362 ++ docs/OrderBookApi.md | 44 + docs/OrderBookL2.md | 14 + docs/Position.md | 100 + docs/PositionApi.md | 166 + docs/Quote.md | 15 + docs/QuoteApi.md | 92 + docs/SchemaApi.md | 65 + docs/Settlement.md | 18 + docs/SettlementApi.md | 49 + docs/Stats.md | 15 + docs/StatsApi.md | 77 + docs/StatsHistory.md | 14 + docs/StatsUsd.md | 15 + docs/Trade.md | 19 + docs/TradeApi.md | 94 + docs/TradeBin.md | 22 + docs/Transaction.md | 21 + docs/User.md | 26 + docs/UserApi.md | 674 ++++ docs/UserCommission.md | 13 + docs/UserPreferences.md | 35 + docs/Wallet.md | 34 + docs/XAny.md | 9 + git_push.sh | 52 + model_access_token.go | 23 + model_affiliate.go | 33 + model_announcement.go | 24 + model_api_key.go | 28 + model_chat.go | 26 + model_chat_channel.go | 16 + model_connected_users.go | 16 + model_error.go | 15 + model_error_error.go | 16 + model_execution.go | 66 + model_funding.go | 24 + model_index_composite.go | 25 + model_inline_response_200.go | 15 + model_inline_response_200_1.go | 15 + model_instrument.go | 120 + model_instrument_interval.go | 16 + model_insurance.go | 22 + model_leaderboard.go | 18 + model_liquidation.go | 20 + model_margin.go | 59 + model_notification.go | 29 + model_order.go | 52 + model_order_book_l2.go | 19 + model_position.go | 110 + model_quote.go | 25 + model_settlement.go | 28 + model_stats.go | 21 + model_stats_history.go | 23 + model_stats_usd.go | 20 + model_trade.go | 29 + model_trade_bin.go | 31 + model_transaction.go | 30 + model_user.go | 36 + model_user_commission.go | 18 + model_user_preferences.go | 44 + model_wallet.go | 43 + model_x_any.go | 14 + response.go | 44 + 118 files changed, 22419 insertions(+), 2 deletions(-) create mode 100644 api/swagger.yaml create mode 100644 api_announcement.go create mode 100644 api_api_key.go create mode 100644 api_chat.go create mode 100644 api_execution.go create mode 100644 api_funding.go create mode 100644 api_instrument.go create mode 100644 api_insurance.go create mode 100644 api_leaderboard.go create mode 100644 api_liquidation.go create mode 100644 api_notification.go create mode 100644 api_order.go create mode 100644 api_order_book.go create mode 100644 api_position.go create mode 100644 api_quote.go create mode 100644 api_schema.go create mode 100644 api_settlement.go create mode 100644 api_stats.go create mode 100644 api_trade.go create mode 100644 api_user.go create mode 100644 client.go create mode 100644 configuration.go create mode 100644 docs/APIKeyApi.md create mode 100644 docs/AccessToken.md create mode 100644 docs/Affiliate.md create mode 100644 docs/Announcement.md create mode 100644 docs/AnnouncementApi.md create mode 100644 docs/ApiKey.md create mode 100644 docs/Chat.md create mode 100644 docs/ChatApi.md create mode 100644 docs/ChatChannel.md create mode 100644 docs/ConnectedUsers.md create mode 100644 docs/ErrorError.md create mode 100644 docs/Execution.md create mode 100644 docs/ExecutionApi.md create mode 100644 docs/Funding.md create mode 100644 docs/FundingApi.md create mode 100644 docs/IndexComposite.md create mode 100644 docs/InlineResponse200.md create mode 100644 docs/InlineResponse2001.md create mode 100644 docs/Instrument.md create mode 100644 docs/InstrumentApi.md create mode 100644 docs/InstrumentInterval.md create mode 100644 docs/Insurance.md create mode 100644 docs/InsuranceApi.md create mode 100644 docs/Leaderboard.md create mode 100644 docs/LeaderboardApi.md create mode 100644 docs/Liquidation.md create mode 100644 docs/LiquidationApi.md create mode 100644 docs/Margin.md create mode 100644 docs/ModelError.md create mode 100644 docs/Notification.md create mode 100644 docs/NotificationApi.md create mode 100644 docs/Order.md create mode 100644 docs/OrderApi.md create mode 100644 docs/OrderBookApi.md create mode 100644 docs/OrderBookL2.md create mode 100644 docs/Position.md create mode 100644 docs/PositionApi.md create mode 100644 docs/Quote.md create mode 100644 docs/QuoteApi.md create mode 100644 docs/SchemaApi.md create mode 100644 docs/Settlement.md create mode 100644 docs/SettlementApi.md create mode 100644 docs/Stats.md create mode 100644 docs/StatsApi.md create mode 100644 docs/StatsHistory.md create mode 100644 docs/StatsUsd.md create mode 100644 docs/Trade.md create mode 100644 docs/TradeApi.md create mode 100644 docs/TradeBin.md create mode 100644 docs/Transaction.md create mode 100644 docs/User.md create mode 100644 docs/UserApi.md create mode 100644 docs/UserCommission.md create mode 100644 docs/UserPreferences.md create mode 100644 docs/Wallet.md create mode 100644 docs/XAny.md create mode 100644 git_push.sh create mode 100644 model_access_token.go create mode 100644 model_affiliate.go create mode 100644 model_announcement.go create mode 100644 model_api_key.go create mode 100644 model_chat.go create mode 100644 model_chat_channel.go create mode 100644 model_connected_users.go create mode 100644 model_error.go create mode 100644 model_error_error.go create mode 100644 model_execution.go create mode 100644 model_funding.go create mode 100644 model_index_composite.go create mode 100644 model_inline_response_200.go create mode 100644 model_inline_response_200_1.go create mode 100644 model_instrument.go create mode 100644 model_instrument_interval.go create mode 100644 model_insurance.go create mode 100644 model_leaderboard.go create mode 100644 model_liquidation.go create mode 100644 model_margin.go create mode 100644 model_notification.go create mode 100644 model_order.go create mode 100644 model_order_book_l2.go create mode 100644 model_position.go create mode 100644 model_quote.go create mode 100644 model_settlement.go create mode 100644 model_stats.go create mode 100644 model_stats_history.go create mode 100644 model_stats_usd.go create mode 100644 model_trade.go create mode 100644 model_trade_bin.go create mode 100644 model_transaction.go create mode 100644 model_user.go create mode 100644 model_user_commission.go create mode 100644 model_user_preferences.go create mode 100644 model_wallet.go create mode 100644 model_x_any.go create mode 100644 response.go diff --git a/README.md b/README.md index 0bface3..fa90cf4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,177 @@ -# bitmexgo -Bitmex RESTful APIs for Go +# Go API client for swagger + +## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + +## Overview +This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. + +- API version: 1.2.0 +- Package version: 1.0.0 +- Build package: io.swagger.codegen.languages.GoClientCodegen + +## Installation +Put the package under your project folder and add the following in import: +```golang +import "./swagger" +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://localhost/api/v1* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*APIKeyApi* | [**APIKeyDisable**](docs/APIKeyApi.md#apikeydisable) | **Post** /apiKey/disable | Disable an API Key. +*APIKeyApi* | [**APIKeyEnable**](docs/APIKeyApi.md#apikeyenable) | **Post** /apiKey/enable | Enable an API Key. +*APIKeyApi* | [**APIKeyGet**](docs/APIKeyApi.md#apikeyget) | **Get** /apiKey | Get your API Keys. +*APIKeyApi* | [**APIKeyNew**](docs/APIKeyApi.md#apikeynew) | **Post** /apiKey | Create a new API Key. +*APIKeyApi* | [**APIKeyRemove**](docs/APIKeyApi.md#apikeyremove) | **Delete** /apiKey | Remove an API Key. +*AnnouncementApi* | [**AnnouncementGet**](docs/AnnouncementApi.md#announcementget) | **Get** /announcement | Get site announcements. +*AnnouncementApi* | [**AnnouncementGetUrgent**](docs/AnnouncementApi.md#announcementgeturgent) | **Get** /announcement/urgent | Get urgent (banner) announcements. +*ChatApi* | [**ChatGet**](docs/ChatApi.md#chatget) | **Get** /chat | Get chat messages. +*ChatApi* | [**ChatGetChannels**](docs/ChatApi.md#chatgetchannels) | **Get** /chat/channels | Get available channels. +*ChatApi* | [**ChatGetConnected**](docs/ChatApi.md#chatgetconnected) | **Get** /chat/connected | Get connected users. +*ChatApi* | [**ChatNew**](docs/ChatApi.md#chatnew) | **Post** /chat | Send a chat message. +*ExecutionApi* | [**ExecutionGet**](docs/ExecutionApi.md#executionget) | **Get** /execution | Get all raw executions for your account. +*ExecutionApi* | [**ExecutionGetTradeHistory**](docs/ExecutionApi.md#executiongettradehistory) | **Get** /execution/tradeHistory | Get all balance-affecting executions. This includes each trade, insurance charge, and settlement. +*FundingApi* | [**FundingGet**](docs/FundingApi.md#fundingget) | **Get** /funding | Get funding history. +*InstrumentApi* | [**InstrumentGet**](docs/InstrumentApi.md#instrumentget) | **Get** /instrument | Get instruments. +*InstrumentApi* | [**InstrumentGetActive**](docs/InstrumentApi.md#instrumentgetactive) | **Get** /instrument/active | Get all active instruments and instruments that have expired in <24hrs. +*InstrumentApi* | [**InstrumentGetActiveAndIndices**](docs/InstrumentApi.md#instrumentgetactiveandindices) | **Get** /instrument/activeAndIndices | Helper method. Gets all active instruments and all indices. This is a join of the result of /indices and /active. +*InstrumentApi* | [**InstrumentGetActiveIntervals**](docs/InstrumentApi.md#instrumentgetactiveintervals) | **Get** /instrument/activeIntervals | Return all active contract series and interval pairs. +*InstrumentApi* | [**InstrumentGetCompositeIndex**](docs/InstrumentApi.md#instrumentgetcompositeindex) | **Get** /instrument/compositeIndex | Show constituent parts of an index. +*InstrumentApi* | [**InstrumentGetIndices**](docs/InstrumentApi.md#instrumentgetindices) | **Get** /instrument/indices | Get all price indices. +*InsuranceApi* | [**InsuranceGet**](docs/InsuranceApi.md#insuranceget) | **Get** /insurance | Get insurance fund history. +*LeaderboardApi* | [**LeaderboardGet**](docs/LeaderboardApi.md#leaderboardget) | **Get** /leaderboard | Get current leaderboard. +*LeaderboardApi* | [**LeaderboardGetName**](docs/LeaderboardApi.md#leaderboardgetname) | **Get** /leaderboard/name | Get your alias on the leaderboard. +*LiquidationApi* | [**LiquidationGet**](docs/LiquidationApi.md#liquidationget) | **Get** /liquidation | Get liquidation orders. +*NotificationApi* | [**NotificationGet**](docs/NotificationApi.md#notificationget) | **Get** /notification | Get your current notifications. +*OrderApi* | [**OrderAmend**](docs/OrderApi.md#orderamend) | **Put** /order | Amend the quantity or price of an open order. +*OrderApi* | [**OrderAmendBulk**](docs/OrderApi.md#orderamendbulk) | **Put** /order/bulk | Amend multiple orders for the same symbol. +*OrderApi* | [**OrderCancel**](docs/OrderApi.md#ordercancel) | **Delete** /order | Cancel order(s). Send multiple order IDs to cancel in bulk. +*OrderApi* | [**OrderCancelAll**](docs/OrderApi.md#ordercancelall) | **Delete** /order/all | Cancels all of your orders. +*OrderApi* | [**OrderCancelAllAfter**](docs/OrderApi.md#ordercancelallafter) | **Post** /order/cancelAllAfter | Automatically cancel all your orders after a specified timeout. +*OrderApi* | [**OrderClosePosition**](docs/OrderApi.md#ordercloseposition) | **Post** /order/closePosition | Close a position. [Deprecated, use POST /order with execInst: 'Close'] +*OrderApi* | [**OrderGetOrders**](docs/OrderApi.md#ordergetorders) | **Get** /order | Get your orders. +*OrderApi* | [**OrderNew**](docs/OrderApi.md#ordernew) | **Post** /order | Create a new order. +*OrderApi* | [**OrderNewBulk**](docs/OrderApi.md#ordernewbulk) | **Post** /order/bulk | Create multiple new orders for the same symbol. +*OrderBookApi* | [**OrderBookGetL2**](docs/OrderBookApi.md#orderbookgetl2) | **Get** /orderBook/L2 | Get current orderbook in vertical format. +*PositionApi* | [**PositionGet**](docs/PositionApi.md#positionget) | **Get** /position | Get your positions. +*PositionApi* | [**PositionIsolateMargin**](docs/PositionApi.md#positionisolatemargin) | **Post** /position/isolate | Enable isolated margin or cross margin per-position. +*PositionApi* | [**PositionTransferIsolatedMargin**](docs/PositionApi.md#positiontransferisolatedmargin) | **Post** /position/transferMargin | Transfer equity in or out of a position. +*PositionApi* | [**PositionUpdateLeverage**](docs/PositionApi.md#positionupdateleverage) | **Post** /position/leverage | Choose leverage for a position. +*PositionApi* | [**PositionUpdateRiskLimit**](docs/PositionApi.md#positionupdaterisklimit) | **Post** /position/riskLimit | Update your risk limit. +*QuoteApi* | [**QuoteGet**](docs/QuoteApi.md#quoteget) | **Get** /quote | Get Quotes. +*QuoteApi* | [**QuoteGetBucketed**](docs/QuoteApi.md#quotegetbucketed) | **Get** /quote/bucketed | Get previous quotes in time buckets. +*SchemaApi* | [**SchemaGet**](docs/SchemaApi.md#schemaget) | **Get** /schema | Get model schemata for data objects returned by this API. +*SchemaApi* | [**SchemaWebsocketHelp**](docs/SchemaApi.md#schemawebsockethelp) | **Get** /schema/websocketHelp | Returns help text & subject list for websocket usage. +*SettlementApi* | [**SettlementGet**](docs/SettlementApi.md#settlementget) | **Get** /settlement | Get settlement history. +*StatsApi* | [**StatsGet**](docs/StatsApi.md#statsget) | **Get** /stats | Get exchange-wide and per-series turnover and volume statistics. +*StatsApi* | [**StatsHistory**](docs/StatsApi.md#statshistory) | **Get** /stats/history | Get historical exchange-wide and per-series turnover and volume statistics. +*StatsApi* | [**StatsHistoryUSD**](docs/StatsApi.md#statshistoryusd) | **Get** /stats/historyUSD | Get a summary of exchange statistics in USD. +*TradeApi* | [**TradeGet**](docs/TradeApi.md#tradeget) | **Get** /trade | Get Trades. +*TradeApi* | [**TradeGetBucketed**](docs/TradeApi.md#tradegetbucketed) | **Get** /trade/bucketed | Get previous trades in time buckets. +*UserApi* | [**UserCancelWithdrawal**](docs/UserApi.md#usercancelwithdrawal) | **Post** /user/cancelWithdrawal | Cancel a withdrawal. +*UserApi* | [**UserCheckReferralCode**](docs/UserApi.md#usercheckreferralcode) | **Get** /user/checkReferralCode | Check if a referral code is valid. +*UserApi* | [**UserConfirm**](docs/UserApi.md#userconfirm) | **Post** /user/confirmEmail | Confirm your email address with a token. +*UserApi* | [**UserConfirmEnableTFA**](docs/UserApi.md#userconfirmenabletfa) | **Post** /user/confirmEnableTFA | Confirm two-factor auth for this account. If using a Yubikey, simply send a token to this endpoint. +*UserApi* | [**UserConfirmWithdrawal**](docs/UserApi.md#userconfirmwithdrawal) | **Post** /user/confirmWithdrawal | Confirm a withdrawal. +*UserApi* | [**UserDisableTFA**](docs/UserApi.md#userdisabletfa) | **Post** /user/disableTFA | Disable two-factor auth for this account. +*UserApi* | [**UserGet**](docs/UserApi.md#userget) | **Get** /user | Get your user model. +*UserApi* | [**UserGetAffiliateStatus**](docs/UserApi.md#usergetaffiliatestatus) | **Get** /user/affiliateStatus | Get your current affiliate/referral status. +*UserApi* | [**UserGetCommission**](docs/UserApi.md#usergetcommission) | **Get** /user/commission | Get your account's commission status. +*UserApi* | [**UserGetDepositAddress**](docs/UserApi.md#usergetdepositaddress) | **Get** /user/depositAddress | Get a deposit address. +*UserApi* | [**UserGetMargin**](docs/UserApi.md#usergetmargin) | **Get** /user/margin | Get your account's margin status. Send a currency of \"all\" to receive an array of all supported currencies. +*UserApi* | [**UserGetWallet**](docs/UserApi.md#usergetwallet) | **Get** /user/wallet | Get your current wallet information. +*UserApi* | [**UserGetWalletHistory**](docs/UserApi.md#usergetwallethistory) | **Get** /user/walletHistory | Get a history of all of your wallet transactions (deposits, withdrawals, PNL). +*UserApi* | [**UserGetWalletSummary**](docs/UserApi.md#usergetwalletsummary) | **Get** /user/walletSummary | Get a summary of all of your wallet transactions (deposits, withdrawals, PNL). +*UserApi* | [**UserLogout**](docs/UserApi.md#userlogout) | **Post** /user/logout | Log out of BitMEX. +*UserApi* | [**UserLogoutAll**](docs/UserApi.md#userlogoutall) | **Post** /user/logoutAll | Log all systems out of BitMEX. This will revoke all of your account's access tokens, logging you out on all devices. +*UserApi* | [**UserMinWithdrawalFee**](docs/UserApi.md#userminwithdrawalfee) | **Get** /user/minWithdrawalFee | Get the minimum withdrawal fee for a currency. +*UserApi* | [**UserRequestEnableTFA**](docs/UserApi.md#userrequestenabletfa) | **Post** /user/requestEnableTFA | Get secret key for setting up two-factor auth. +*UserApi* | [**UserRequestWithdrawal**](docs/UserApi.md#userrequestwithdrawal) | **Post** /user/requestWithdrawal | Request a withdrawal to an external wallet. +*UserApi* | [**UserSavePreferences**](docs/UserApi.md#usersavepreferences) | **Post** /user/preferences | Save user preferences. +*UserApi* | [**UserUpdate**](docs/UserApi.md#userupdate) | **Put** /user | Update your password, name, and other attributes. + + +## Documentation For Models + + - [AccessToken](docs/AccessToken.md) + - [Affiliate](docs/Affiliate.md) + - [Announcement](docs/Announcement.md) + - [ApiKey](docs/ApiKey.md) + - [Chat](docs/Chat.md) + - [ChatChannel](docs/ChatChannel.md) + - [ConnectedUsers](docs/ConnectedUsers.md) + - [ErrorError](docs/ErrorError.md) + - [Execution](docs/Execution.md) + - [Funding](docs/Funding.md) + - [IndexComposite](docs/IndexComposite.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [InlineResponse2001](docs/InlineResponse2001.md) + - [Instrument](docs/Instrument.md) + - [InstrumentInterval](docs/InstrumentInterval.md) + - [Insurance](docs/Insurance.md) + - [Leaderboard](docs/Leaderboard.md) + - [Liquidation](docs/Liquidation.md) + - [Margin](docs/Margin.md) + - [ModelError](docs/ModelError.md) + - [Notification](docs/Notification.md) + - [Order](docs/Order.md) + - [OrderBookL2](docs/OrderBookL2.md) + - [Position](docs/Position.md) + - [Quote](docs/Quote.md) + - [Settlement](docs/Settlement.md) + - [Stats](docs/Stats.md) + - [StatsHistory](docs/StatsHistory.md) + - [StatsUsd](docs/StatsUsd.md) + - [Trade](docs/Trade.md) + - [TradeBin](docs/TradeBin.md) + - [Transaction](docs/Transaction.md) + - [User](docs/User.md) + - [UserCommission](docs/UserCommission.md) + - [UserPreferences](docs/UserPreferences.md) + - [Wallet](docs/Wallet.md) + - [XAny](docs/XAny.md) + + +## Documentation For Authorization + +## apiKey +- **Type**: API key + +Example +```golang +auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ + Key: "APIKEY", + Prefix: "Bearer", // Omit if not necessary. +}) +r, err := client.Service.Operation(auth, args) +``` +## apiNonce +- **Type**: API key + +Example +```golang +auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ + Key: "APIKEY", + Prefix: "Bearer", // Omit if not necessary. +}) +r, err := client.Service.Operation(auth, args) +``` +## apiSignature +- **Type**: API key + +Example +```golang +auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ + Key: "APIKEY", + Prefix: "Bearer", // Omit if not necessary. +}) +r, err := client.Service.Operation(auth, args) +``` + +## Author + +support@bitmex.com + diff --git a/api/swagger.yaml b/api/swagger.yaml new file mode 100644 index 0000000..3b8968e --- /dev/null +++ b/api/swagger.yaml @@ -0,0 +1,5992 @@ +--- +swagger: "2.0" +info: + description: "## REST API for the BitMEX Trading Platform\n\n[View Changelog](/app/apiChangelog)\n\ + \n\n\n#### Getting Started\n\nBase URI: [https://www.bitmex.com/api/v1](/api/v1)\n\ + \n##### Fetching Data\n\nAll REST endpoints are documented below. You can try\ + \ out any query right from this interface.\n\nMost table queries accept `count`,\ + \ `start`, and `reverse` params. Set `reverse=true` to get rows newest-first.\n\ + \nAdditional documentation regarding filters, timestamps, and authentication\n\ + is available in [the main API documentation](/app/restAPI).\n\n*All* table data\ + \ is available via the [Websocket](/app/wsAPI). We highly recommend using the\ + \ socket if you want\nto have the quickest possible data without being subject\ + \ to ratelimits.\n\n##### Return Types\n\nBy default, all data is returned as\ + \ JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data.\n\ + \n##### Trade Data Queries\n\n*This is only a small subset of what is available,\ + \ to get you started.*\n\nFill in the parameters and click the `Try it out!` button\ + \ to try any of these queries.\n\n* [Pricing Data](#!/Quote/Quote_get)\n\n* [Trade\ + \ Data](#!/Trade/Trade_get)\n\n* [OrderBook Data](#!/OrderBook/OrderBook_getL2)\n\ + \n* [Settlement Data](#!/Settlement/Settlement_get)\n\n* [Exchange Statistics](#!/Stats/Stats_history)\n\ + \nEvery function of the BitMEX.com platform is exposed here and documented. Many\ + \ more functions are available.\n\n##### Swagger Specification\n\n[⇩ Download\ + \ Swagger JSON](swagger.json)\n\n\n\n## All API Endpoints\n\nClick to expand a\ + \ section.\n" + version: "1.2.0" + title: "BitMEX API" + termsOfService: "https://www.bitmex.com/app/terms" + contact: + email: "support@bitmex.com" +basePath: "/api/v1" +tags: +- name: "Announcement" + description: "Public Announcements" +- name: "APIKey" + description: "Persistent API Keys for Developers" +- name: "Chat" + description: "Trollbox Data" +- name: "Execution" + description: "Raw Order and Balance Data" +- name: "Funding" + description: "Swap Funding History" +- name: "Instrument" + description: "Tradeable Contracts, Indices, and History" +- name: "Insurance" + description: "Insurance Fund Data" +- name: "Leaderboard" + description: "Information on Top Users" +- name: "Liquidation" + description: "Active Liquidations" +- name: "Notification" + description: "Account Notifications" +- name: "Order" + description: "Placement, Cancellation, Amending, and History" +- name: "OrderBook" + description: "Level 2 Book Data" +- name: "Position" + description: "Summary of Open and Closed Positions" +- name: "Quote" + description: "Best Bid/Offer Snapshots & Historical Bins" +- name: "Schema" + description: "Dynamic Schemata for Developers" +- name: "Settlement" + description: "Historical Settlement Data" +- name: "Stats" + description: "Exchange Statistics" +- name: "Trade" + description: "Individual & Bucketed Trades" +- name: "User" + description: "Account Operations" +consumes: +- "application/json" +- "application/x-www-form-urlencoded" +produces: +- "application/json" +- "application/xml" +- "text/xml" +- "application/javascript" +- "text/javascript" +security: +- apiKey: [] + apiSignature: [] + apiNonce: [] +paths: + /announcement: + get: + tags: + - "Announcement" + summary: "Get site announcements." + operationId: "Announcement.get" + parameters: + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Announcement" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /announcement/urgent: + get: + tags: + - "Announcement" + summary: "Get urgent (banner) announcements." + operationId: "Announcement.getUrgent" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Announcement" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /apiKey: + get: + tags: + - "APIKey" + summary: "Get your API Keys." + operationId: "APIKey.get" + parameters: + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/APIKey" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + post: + tags: + - "APIKey" + summary: "Create a new API Key." + description: "API Keys can only be created via the frontend." + operationId: "APIKey.new" + parameters: + - name: "name" + in: "formData" + description: "Key name. This name is for reference only." + required: false + type: "string" + x-exportParamName: "Name" + x-optionalDataType: "String" + - name: "cidr" + in: "formData" + description: "CIDR block to restrict this key to. To restrict to a single\ + \ address, append \"/32\", e.g. 207.39.29.22/32. Leave blank or set to 0.0.0.0/0\ + \ to allow all IPs. Only one block may be set. More on CIDR blocks" + required: false + type: "string" + x-exportParamName: "Cidr" + x-optionalDataType: "String" + - name: "permissions" + in: "formData" + description: "Key Permissions. All keys can read margin and position data.\ + \ Additional permissions must be added. Available: [\"order\", \"orderCancel\"\ + , \"withdraw\"]." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Permissions" + x-optionalDataType: "String" + - name: "enabled" + in: "formData" + description: "Set to true to enable this key on creation. Otherwise, it must\ + \ be explicitly enabled via /apiKey/enable." + required: false + type: "boolean" + default: false + x-exportParamName: "Enabled" + x-optionalDataType: "Bool" + - name: "token" + in: "formData" + description: "OTP Token (YubiKey, Google Authenticator)" + required: false + type: "string" + x-exportParamName: "Token" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/APIKey" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + delete: + tags: + - "APIKey" + summary: "Remove an API Key." + operationId: "APIKey.remove" + parameters: + - name: "apiKeyID" + in: "formData" + description: "API Key ID (public component)." + required: true + type: "string" + x-exportParamName: "ApiKeyID" + responses: + 200: + description: "Request was successful" + schema: + type: "object" + properties: + success: + type: "boolean" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /apiKey/disable: + post: + tags: + - "APIKey" + summary: "Disable an API Key." + operationId: "APIKey.disable" + parameters: + - name: "apiKeyID" + in: "formData" + description: "API Key ID (public component)." + required: true + type: "string" + x-exportParamName: "ApiKeyID" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/APIKey" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /apiKey/enable: + post: + tags: + - "APIKey" + summary: "Enable an API Key." + operationId: "APIKey.enable" + parameters: + - name: "apiKeyID" + in: "formData" + description: "API Key ID (public component)." + required: true + type: "string" + x-exportParamName: "ApiKeyID" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/APIKey" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /chat: + get: + tags: + - "Chat" + summary: "Get chat messages." + operationId: "Chat.get" + parameters: + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting ID for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: true + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "channelID" + in: "query" + description: "Channel id. GET /chat/channels for ids. Leave blank for all." + required: false + type: "number" + format: "double" + x-exportParamName: "ChannelID" + x-optionalDataType: "Float64" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Chat" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + post: + tags: + - "Chat" + summary: "Send a chat message." + operationId: "Chat.new" + parameters: + - name: "message" + in: "formData" + required: true + type: "string" + x-exportParamName: "Message" + - name: "channelID" + in: "formData" + description: "Channel to post to. Default 1 (English)." + required: false + type: "number" + default: 1.0 + format: "double" + x-exportParamName: "ChannelID" + x-optionalDataType: "Float64" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Chat" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /chat/channels: + get: + tags: + - "Chat" + summary: "Get available channels." + operationId: "Chat.getChannels" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/ChatChannel" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /chat/connected: + get: + tags: + - "Chat" + summary: "Get connected users." + description: "Returns an array with browser users in the first position and\ + \ API users (bots) in the second position." + operationId: "Chat.getConnected" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/ConnectedUsers" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /execution: + get: + tags: + - "Execution" + summary: "Get all raw executions for your account." + description: "This returns all raw transactions, which includes order opening\ + \ and cancelation, and order status\nchanges. It can be quite noisy. More\ + \ focused information is available at `/execution/tradeHistory`.\n\nYou may\ + \ also use the `filter` param to target your query. Specify an array as a\ + \ filter value, such as\n`{\"execType\": [\"Settlement\", \"Trade\"]}` to\ + \ filter on multiple values.\n\nSee [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_8_8.html)\ + \ for explanations of these fields.\n" + operationId: "Execution.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Execution" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /execution/tradeHistory: + get: + tags: + - "Execution" + summary: "Get all balance-affecting executions. This includes each trade, insurance\ + \ charge, and settlement." + operationId: "Execution.getTradeHistory" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Execution" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /funding: + get: + tags: + - "Funding" + summary: "Get funding history." + operationId: "Funding.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Funding" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument: + get: + tags: + - "Instrument" + summary: "Get instruments." + description: "This returns all instruments and indices, including those that\ + \ have settled or are unlisted. Use this endpoint if you want to query for\ + \ individual instruments or use a complex filter. Use `/instrument/active`\ + \ to return active instruments, or use a filter like `{\"state\": \"Open\"\ + }`." + operationId: "Instrument.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Instrument" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument/active: + get: + tags: + - "Instrument" + summary: "Get all active instruments and instruments that have expired in <24hrs." + operationId: "Instrument.getActive" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Instrument" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument/indices: + get: + tags: + - "Instrument" + summary: "Get all price indices." + operationId: "Instrument.getIndices" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Instrument" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument/activeAndIndices: + get: + tags: + - "Instrument" + summary: "Helper method. Gets all active instruments and all indices. This is\ + \ a join of the result of /indices and /active." + operationId: "Instrument.getActiveAndIndices" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Instrument" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument/activeIntervals: + get: + tags: + - "Instrument" + summary: "Return all active contract series and interval pairs." + description: "This endpoint is useful for determining which pairs are live.\ + \ It returns two arrays of strings. The first is intervals, such as `[\"\ + XBT:perpetual\", \"XBT:monthly\", \"XBT:quarterly\", \"ETH:monthly\", ...]`.\ + \ These identifiers are usable in any query's `symbol` param. The second array\ + \ is the current resolution of these intervals. Results are mapped at the\ + \ same index." + operationId: "Instrument.getActiveIntervals" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/InstrumentInterval" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /instrument/compositeIndex: + get: + tags: + - "Instrument" + summary: "Show constituent parts of an index." + description: "Composite indices are built from multiple external price sources.\n\ + \nUse this endpoint to get the underlying prices of an index. For example,\ + \ send a `symbol` of `.XBT` to\nget the ticks and weights of the constituent\ + \ exchanges that build the \".XBT\" index.\n\nA tick with reference `\"BMI\"\ + ` and weight `null` is the composite index tick.\n" + operationId: "Instrument.getCompositeIndex" + parameters: + - name: "account" + in: "query" + required: false + type: "number" + format: "double" + x-exportParamName: "Account" + x-optionalDataType: "Float64" + - name: "symbol" + in: "query" + description: "The composite index symbol." + required: false + type: "string" + default: ".XBT" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/IndexComposite" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /insurance: + get: + tags: + - "Insurance" + summary: "Get insurance fund history." + operationId: "Insurance.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Insurance" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /leaderboard: + get: + tags: + - "Leaderboard" + summary: "Get current leaderboard." + operationId: "Leaderboard.get" + parameters: + - name: "method" + in: "query" + description: "Ranking type. Options: \"notional\", \"ROE\"" + required: false + type: "string" + default: "notional" + x-exportParamName: "Method" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Leaderboard" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /leaderboard/name: + get: + tags: + - "Leaderboard" + summary: "Get your alias on the leaderboard." + operationId: "Leaderboard.getName" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "object" + properties: + name: + type: "string" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /liquidation: + get: + tags: + - "Liquidation" + summary: "Get liquidation orders." + operationId: "Liquidation.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Liquidation" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /notification: + get: + tags: + - "Notification" + summary: "Get your current notifications." + description: "This is an upcoming feature and currently does not return data." + operationId: "Notification.get" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Notification" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /order: + get: + tags: + - "Order" + summary: "Get your orders." + description: "To get open orders only, send {\"open\": true} in the filter param.\n\ + \nSee the FIX Spec for explanations of these fields." + operationId: "Order.getOrders" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + post: + tags: + - "Order" + summary: "Create a new order." + description: "## Placing Orders\n\nThis endpoint is used for placing orders.\ + \ See individual fields below for more details on their use.\n\n#### Order\ + \ Types\n\nAll orders require a `symbol`. All other fields are optional except\ + \ when otherwise specified.\n\nThese are the valid `ordType`s:\n\n* **Limit**:\ + \ The default order type. Specify an `orderQty` and `price`.\n* **Market**:\ + \ A traditional Market order. A Market order will execute until filled or\ + \ your bankruptcy price is reached, at\n which point it will cancel.\n* **MarketWithLeftOverAsLimit**:\ + \ A market order that, after eating through the order book as far as\n permitted\ + \ by available margin, will become a limit order. The difference between this\ + \ type and `Market` only\n affects the behavior in thin books. Upon reaching\ + \ the deepest possible price, if there is quantity left over,\n a `Market`\ + \ order will cancel the remaining quantity. `MarketWithLeftOverAsLimit` will\ + \ keep the remaining\n quantity in the books as a `Limit`.\n* **Stop**: A\ + \ Stop Market order. Specify an `orderQty` and `stopPx`. When the `stopPx`\ + \ is reached, the order will be entered\n into the book.\n * On sell orders,\ + \ the order will trigger if the triggering price is lower than the `stopPx`.\ + \ On buys, higher.\n * Note: Stop orders do not consume margin until triggered.\ + \ Be sure that the required margin is available in your\n account so that\ + \ it may trigger fully.\n * `Close` Stops don't require an `orderQty`. See\ + \ Execution Instructions below.\n* **StopLimit**: Like a Stop Market, but\ + \ enters a Limit order instead of a Market order. Specify an `orderQty`, `stopPx`,\n\ + \ and `price`.\n* **MarketIfTouched**: Similar to a Stop, but triggers are\ + \ done in the opposite direction. Useful for Take Profit orders.\n* **LimitIfTouched**:\ + \ As above; use for Take Profit Limit orders.\n\n#### Execution Instructions\n\ + \nThe following `execInst`s are supported. If using multiple, separate with\ + \ a comma (e.g. `LastPrice,Close`).\n\n* **ParticipateDoNotInitiate**: Also\ + \ known as a Post-Only order. If this order would have executed on placement,\n\ + \ it will cancel instead.\n* **AllOrNone**: Valid only for hidden orders\ + \ (`displayQty: 0`). Use to only execute if the entire order would fill.\n\ + * **MarkPrice, LastPrice, IndexPrice**: Used by stop and if-touched orders\ + \ to determine the triggering price.\n Use only one. By default, `'MarkPrice'`\ + \ is used. Also used for Pegged orders to define the value of `'LastPeg'`.\n\ + * **ReduceOnly**: A `'ReduceOnly'` order can only reduce your position, not\ + \ increase it. If you have a `'ReduceOnly'`\n limit order that rests in the\ + \ order book while the position is reduced by other orders, then its order\ + \ quantity will\n be amended down or canceled. If there are multiple `'ReduceOnly'`\ + \ orders the least agresssive will be amended first.\n* **Close**: `'Close'`\ + \ implies `'ReduceOnly'`. A `'Close'` order will cancel other active limit\ + \ orders with the same side\n and symbol if the open quantity exceeds the\ + \ current position. This is useful for stops: by canceling these orders, a\n\ + \ `'Close'` Stop is ensured to have the margin required to execute, and can\ + \ only execute up to the full size of your\n position. If `orderQty` is not\ + \ specified, a `'Close'` order has an `orderQty` equal to your current position's\ + \ size.\n * Note that a `Close` order without an `orderQty` requires a `side`,\ + \ so that BitMEX knows if it should trigger\n above or below the `stopPx`.\n\ + \n#### Linked Orders\n\nLinked Orders are an advanced capability. It is very\ + \ powerful, but its use requires careful coding and testing.\nPlease follow\ + \ this document carefully and use the [Testnet Exchange](https://testnet.bitmex.com)\ + \ while developing.\n\nBitMEX offers four advanced Linked Order types:\n\n\ + * **OCO**: *One Cancels the Other*. A very flexible version of the standard\ + \ Stop / Take Profit technique.\n Multiple orders may be linked together\ + \ using a single `clOrdLinkID`. Send a `contingencyType` of\n `OneCancelsTheOther`\ + \ on the orders. The first order that fully or partially executes (or activates\n\ + \ for `Stop` orders) will cancel all other orders with the same `clOrdLinkID`.\n\ + * **OTO**: *One Triggers the Other*. Send a `contingencyType` of `'OneTriggersTheOther'`\ + \ on the primary order and\n then subsequent orders with the same `clOrdLinkID`\ + \ will be not be triggered until the primary order fully executes.\n* **OUOA**:\ + \ *One Updates the Other Absolute*. Send a `contingencyType` of `'OneUpdatesTheOtherAbsolute'`\ + \ on the orders. Then\n as one order has a execution, other orders with the\ + \ same `clOrdLinkID` will have their order quantity amended\n down by the\ + \ execution quantity.\n* **OUOP**: *One Updates the Other Proportional*. Send\ + \ a `contingencyType` of `'OneUpdatesTheOtherProportional'` on the orders.\ + \ Then\n as one order has a execution, other orders with the same `clOrdLinkID`\ + \ will have their order quantity reduced proportionally\n by the fill percentage.\n\ + \n#### Trailing Stops\n\nYou may use `pegPriceType` of `'TrailingStopPeg'`\ + \ to create Trailing Stops. The pegged `stopPx` will move as the market\n\ + moves away from the peg, and freeze as the market moves toward it.\n\nTo use,\ + \ combine with `pegOffsetValue` to set the `stopPx` of your order. The peg\ + \ is set to the triggering price\nspecified in the `execInst` (default `'MarkPrice'`).\ + \ Use a negative offset for stop-sell and buy-if-touched orders.\n\nRequires\ + \ `ordType`: `'Stop', 'StopLimit', 'MarketIfTouched', 'LimitIfTouched'`.\n\ + \n#### Simple Quantities\n\nSend a `simpleOrderQty` instead of an `orderQty`\ + \ to create an order denominated in the underlying currency.\nThis is useful\ + \ for opening up a position with 1 XBT of exposure without having to calculate\ + \ how many contracts it is.\n\n#### Rate Limits\n\nSee the [Bulk Order Documentation](#!/Order/Order_newBulk)\ + \ if you need to place multiple orders at the same time.\nBulk orders require\ + \ fewer risk checks in the trading engine and thus are ratelimited at **1/10**\ + \ the normal rate.\n\nYou can also improve your reactivity to market movements\ + \ while staying under your ratelimit by using the\n[Amend](#!/Order/Order_amend)\ + \ and [Amend Bulk](#!/Order/Order_amendBulk) endpoints. This allows you to\ + \ stay\nin the market and avoids the cancel/replace cycle.\n\n#### Tracking\ + \ Your Orders\n\nIf you want to keep track of order IDs yourself, set a unique\ + \ `clOrdID` per order.\nThis `clOrdID` will come back as a property on the\ + \ order and any related executions (including on the WebSocket),\nand can\ + \ be used to get or cancel the order. Max length is 36 characters.\n\nYou\ + \ can also change the `clOrdID` by amending an order, supplying an `origClOrdID`,\ + \ and your desired new\nID as the `clOrdID` param, like so:\n\n```\n# Amends\ + \ an order's leavesQty, and updates its clOrdID to \"def-456\"\nPUT /api/v1/order\ + \ {\"origClOrdID\": \"abc-123\", \"clOrdID\": \"def-456\", \"leavesQty\":\ + \ 1000}\n```\n" + operationId: "Order.new" + parameters: + - name: "symbol" + in: "formData" + description: "Instrument symbol. e.g. 'XBTUSD'." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "side" + in: "formData" + description: "Order side. Valid options: Buy, Sell. Defaults to 'Buy' unless\ + \ `orderQty` or `simpleOrderQty` is negative." + required: false + type: "string" + x-exportParamName: "Side" + x-optionalDataType: "String" + - name: "simpleOrderQty" + in: "formData" + description: "Order quantity in units of the underlying instrument (i.e. Bitcoin)." + required: false + type: "number" + format: "double" + x-exportParamName: "SimpleOrderQty" + x-optionalDataType: "Float64" + - name: "orderQty" + in: "formData" + description: "Order quantity in units of the instrument (i.e. contracts)." + required: false + type: "number" + format: "int32" + x-exportParamName: "OrderQty" + x-optionalDataType: "Float32" + - name: "price" + in: "formData" + description: "Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched'\ + \ orders." + required: false + type: "number" + format: "double" + x-exportParamName: "Price" + x-optionalDataType: "Float64" + - name: "displayQty" + in: "formData" + description: "Optional quantity to display in the book. Use 0 for a fully\ + \ hidden order." + required: false + type: "number" + format: "int32" + x-exportParamName: "DisplayQty" + x-optionalDataType: "Float32" + - name: "stopPx" + in: "formData" + description: "Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched',\ + \ and 'LimitIfTouched' orders. Use a price below the current price for stop-sell\ + \ orders and buy-if-touched orders. Use `execInst` of 'MarkPrice' or 'LastPrice'\ + \ to define the current price used for triggering." + required: false + type: "number" + format: "double" + x-exportParamName: "StopPx" + x-optionalDataType: "Float64" + - name: "clOrdID" + in: "formData" + description: "Optional Client Order ID. This clOrdID will come back on the\ + \ order and any related executions." + required: false + type: "string" + x-exportParamName: "ClOrdID" + x-optionalDataType: "String" + - name: "clOrdLinkID" + in: "formData" + description: "Optional Client Order Link ID for contingent orders." + required: false + type: "string" + x-exportParamName: "ClOrdLinkID" + x-optionalDataType: "String" + - name: "pegOffsetValue" + in: "formData" + description: "Optional trailing offset from the current price for 'Stop',\ + \ 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative\ + \ offset for stop-sell orders and buy-if-touched orders. Optional offset\ + \ from the peg price for 'Pegged' orders." + required: false + type: "number" + format: "double" + x-exportParamName: "PegOffsetValue" + x-optionalDataType: "Float64" + - name: "pegPriceType" + in: "formData" + description: "Optional peg price type. Valid options: LastPeg, MidPricePeg,\ + \ MarketPeg, PrimaryPeg, TrailingStopPeg." + required: false + type: "string" + x-exportParamName: "PegPriceType" + x-optionalDataType: "String" + - name: "ordType" + in: "formData" + description: "Order type. Valid options: Market, Limit, Stop, StopLimit, MarketIfTouched,\ + \ LimitIfTouched, MarketWithLeftOverAsLimit, Pegged. Defaults to 'Limit'\ + \ when `price` is specified. Defaults to 'Stop' when `stopPx` is specified.\ + \ Defaults to 'StopLimit' when `price` and `stopPx` are specified." + required: false + type: "string" + default: "Limit" + x-exportParamName: "OrdType" + x-optionalDataType: "String" + - name: "timeInForce" + in: "formData" + description: "Time in force. Valid options: Day, GoodTillCancel, ImmediateOrCancel,\ + \ FillOrKill. Defaults to 'GoodTillCancel' for 'Limit', 'StopLimit', 'LimitIfTouched',\ + \ and 'MarketWithLeftOverAsLimit' orders." + required: false + type: "string" + x-exportParamName: "TimeInForce" + x-optionalDataType: "String" + - name: "execInst" + in: "formData" + description: "Optional execution instructions. Valid options: ParticipateDoNotInitiate,\ + \ AllOrNone, MarkPrice, IndexPrice, LastPrice, Close, ReduceOnly, Fixed.\ + \ 'AllOrNone' instruction requires `displayQty` to be 0. 'MarkPrice', 'IndexPrice'\ + \ or 'LastPrice' instruction valid for 'Stop', 'StopLimit', 'MarketIfTouched',\ + \ and 'LimitIfTouched' orders." + required: false + type: "string" + x-exportParamName: "ExecInst" + x-optionalDataType: "String" + - name: "contingencyType" + in: "formData" + description: "Optional contingency type for use with `clOrdLinkID`. Valid\ + \ options: OneCancelsTheOther, OneTriggersTheOther, OneUpdatesTheOtherAbsolute,\ + \ OneUpdatesTheOtherProportional." + required: false + type: "string" + x-exportParamName: "ContingencyType" + x-optionalDataType: "String" + - name: "text" + in: "formData" + description: "Optional order annotation. e.g. 'Take profit'." + required: false + type: "string" + x-exportParamName: "Text" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + put: + tags: + - "Order" + summary: "Amend the quantity or price of an open order." + description: "Send an `orderID` or `origClOrdID` to identify the order you wish\ + \ to amend.\n\nBoth order quantity and price can be amended. Only one `qty`\ + \ field can be used to amend.\n\nUse the `leavesQty` field to specify how\ + \ much of the order you wish to remain open. This can be useful\nif you want\ + \ to adjust your position's delta by a certain amount, regardless of how much\ + \ of the order has\nalready filled.\n\n> A `leavesQty` can be used to make\ + \ a \"Filled\" order live again, if it is received within 60 seconds of the\ + \ fill.\n\nUse the `simpleOrderQty` and `simpleLeavesQty` fields to specify\ + \ order size in Bitcoin, rather than contracts.\nThese fields will round up\ + \ to the nearest contract.\n\nLike order placement, amending can be done in\ + \ bulk. Simply send a request to `PUT /api/v1/order/bulk` with\na JSON body\ + \ of the shape: `{\"orders\": [{...}, {...}]}`, each object containing the\ + \ fields used in this endpoint.\n" + operationId: "Order.amend" + parameters: + - name: "orderID" + in: "formData" + description: "Order ID" + required: false + type: "string" + x-exportParamName: "OrderID" + x-optionalDataType: "String" + - name: "origClOrdID" + in: "formData" + description: "Client Order ID. See POST /order." + required: false + type: "string" + x-exportParamName: "OrigClOrdID" + x-optionalDataType: "String" + - name: "clOrdID" + in: "formData" + description: "Optional new Client Order ID, requires `origClOrdID`." + required: false + type: "string" + x-exportParamName: "ClOrdID" + x-optionalDataType: "String" + - name: "simpleOrderQty" + in: "formData" + description: "Optional order quantity in units of the underlying instrument\ + \ (i.e. Bitcoin)." + required: false + type: "number" + format: "double" + x-exportParamName: "SimpleOrderQty" + x-optionalDataType: "Float64" + - name: "orderQty" + in: "formData" + description: "Optional order quantity in units of the instrument (i.e. contracts)." + required: false + type: "number" + format: "int32" + x-exportParamName: "OrderQty" + x-optionalDataType: "Float32" + - name: "simpleLeavesQty" + in: "formData" + description: "Optional leaves quantity in units of the underlying instrument\ + \ (i.e. Bitcoin). Useful for amending partially filled orders." + required: false + type: "number" + format: "double" + x-exportParamName: "SimpleLeavesQty" + x-optionalDataType: "Float64" + - name: "leavesQty" + in: "formData" + description: "Optional leaves quantity in units of the instrument (i.e. contracts).\ + \ Useful for amending partially filled orders." + required: false + type: "number" + format: "int32" + x-exportParamName: "LeavesQty" + x-optionalDataType: "Float32" + - name: "price" + in: "formData" + description: "Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched'\ + \ orders." + required: false + type: "number" + format: "double" + x-exportParamName: "Price" + x-optionalDataType: "Float64" + - name: "stopPx" + in: "formData" + description: "Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched',\ + \ and 'LimitIfTouched' orders. Use a price below the current price for stop-sell\ + \ orders and buy-if-touched orders." + required: false + type: "number" + format: "double" + x-exportParamName: "StopPx" + x-optionalDataType: "Float64" + - name: "pegOffsetValue" + in: "formData" + description: "Optional trailing offset from the current price for 'Stop',\ + \ 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative\ + \ offset for stop-sell orders and buy-if-touched orders. Optional offset\ + \ from the peg price for 'Pegged' orders." + required: false + type: "number" + format: "double" + x-exportParamName: "PegOffsetValue" + x-optionalDataType: "Float64" + - name: "text" + in: "formData" + description: "Optional amend annotation. e.g. 'Adjust skew'." + required: false + type: "string" + x-exportParamName: "Text" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + delete: + tags: + - "Order" + summary: "Cancel order(s). Send multiple order IDs to cancel in bulk." + description: "Either an orderID or a clOrdID must be provided." + operationId: "Order.cancel" + parameters: + - name: "orderID" + in: "formData" + description: "Order ID(s)." + required: false + type: "string" + format: "JSON" + x-exportParamName: "OrderID" + x-optionalDataType: "String" + - name: "clOrdID" + in: "formData" + description: "Client Order ID(s). See POST /order." + required: false + type: "string" + format: "JSON" + x-exportParamName: "ClOrdID" + x-optionalDataType: "String" + - name: "text" + in: "formData" + description: "Optional cancellation annotation. e.g. 'Spread Exceeded'." + required: false + type: "string" + x-exportParamName: "Text" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /order/bulk: + post: + tags: + - "Order" + summary: "Create multiple new orders for the same symbol." + description: "This endpoint is used for placing bulk orders. Valid order types\ + \ are Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit,\ + \ and Pegged.\n\nEach individual order object in the array should have the\ + \ same properties as an individual POST /order call.\n\nThis endpoint is much\ + \ faster for getting many orders into the book at once. Because it reduces\ + \ load on BitMEX\nsystems, this endpoint is ratelimited at `ceil(0.1 * orders)`.\ + \ Submitting 10 orders via a bulk order call\nwill only count as 1 request,\ + \ 15 as 2, 32 as 4, and so on.\n\nFor now, only `application/json` is supported\ + \ on this endpoint.\n" + operationId: "Order.newBulk" + parameters: + - name: "orders" + in: "formData" + description: "An array of orders." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Orders" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + put: + tags: + - "Order" + summary: "Amend multiple orders for the same symbol." + description: "Similar to POST /amend, but with multiple orders. `application/json`\ + \ only. Ratelimited at 10%." + operationId: "Order.amendBulk" + parameters: + - name: "orders" + in: "formData" + description: "An array of orders." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Orders" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /order/closePosition: + post: + tags: + - "Order" + summary: "Close a position. [Deprecated, use POST /order with execInst: 'Close']" + description: "If no `price` is specified, a market order will be submitted to\ + \ close the whole of your position. This will also close all other open orders\ + \ in this symbol." + operationId: "Order.closePosition" + parameters: + - name: "symbol" + in: "formData" + description: "Symbol of position to close." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "price" + in: "formData" + description: "Optional limit price." + required: false + type: "number" + format: "double" + x-exportParamName: "Price" + x-optionalDataType: "Float64" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /order/all: + delete: + tags: + - "Order" + summary: "Cancels all of your orders." + operationId: "Order.cancelAll" + parameters: + - name: "symbol" + in: "formData" + description: "Optional symbol. If provided, only cancels orders for that symbol." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "formData" + description: "Optional filter for cancellation. Use to only cancel some orders,\ + \ e.g. `{\"side\": \"Buy\"}`." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "text" + in: "formData" + description: "Optional cancellation annotation. e.g. 'Spread Exceeded'" + required: false + type: "string" + x-exportParamName: "Text" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Order" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /order/cancelAllAfter: + post: + tags: + - "Order" + summary: "Automatically cancel all your orders after a specified timeout." + description: "Useful as a dead-man's switch to ensure your orders are canceled\ + \ in case of an outage.\nIf called repeatedly, the existing offset will be\ + \ canceled and a new one will be inserted in its place.\n\nExample usage:\ + \ call this route at 15s intervals with an offset of 60000 (60s).\nIf this\ + \ route is not called within 60 seconds, all your orders will be automatically\ + \ canceled.\n\nThis is also available via [WebSocket](https://www.bitmex.com/app/wsAPI#Dead-Mans-Switch-Auto-Cancel).\n" + operationId: "Order.cancelAllAfter" + parameters: + - name: "timeout" + in: "formData" + description: "Timeout in ms. Set to 0 to cancel this timer. " + required: true + type: "number" + format: "double" + x-exportParamName: "Timeout" + responses: + 200: + description: "Request was successful" + schema: + type: "object" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /orderBook/L2: + get: + tags: + - "OrderBook" + summary: "Get current orderbook in vertical format." + operationId: "OrderBook.getL2" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a series (e.g. XBT) to get data for\ + \ the nearest contract in that series." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "depth" + in: "query" + description: "Orderbook depth per side. Send 0 for full depth." + required: false + type: "number" + default: 25.0 + minimum: 0 + format: "int32" + x-exportParamName: "Depth" + x-optionalDataType: "Float32" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/OrderBookL2" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /position: + get: + tags: + - "Position" + summary: "Get your positions." + description: "See the FIX Spec for explanations of these fields." + operationId: "Position.get" + parameters: + - name: "filter" + in: "query" + description: "Table filter. For example, send {\"symbol\": \"XBTUSD\"}." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Which columns to fetch. For example, send [\"columnName\"]." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of rows to fetch." + required: false + type: "number" + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Position" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /position/isolate: + post: + tags: + - "Position" + summary: "Enable isolated margin or cross margin per-position." + operationId: "Position.isolateMargin" + parameters: + - name: "symbol" + in: "formData" + description: "Position symbol to isolate." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "enabled" + in: "formData" + description: "True for isolated margin, false for cross margin." + required: false + type: "boolean" + default: true + x-exportParamName: "Enabled" + x-optionalDataType: "Bool" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Position" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /position/riskLimit: + post: + tags: + - "Position" + summary: "Update your risk limit." + operationId: "Position.updateRiskLimit" + parameters: + - name: "symbol" + in: "formData" + description: "Symbol of position to update risk limit on." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "riskLimit" + in: "formData" + description: "New Risk Limit, in Satoshis." + required: true + type: "number" + format: "int64" + x-exportParamName: "RiskLimit" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Position" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /position/transferMargin: + post: + tags: + - "Position" + summary: "Transfer equity in or out of a position." + operationId: "Position.transferIsolatedMargin" + parameters: + - name: "symbol" + in: "formData" + description: "Symbol of position to isolate." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "amount" + in: "formData" + description: "Amount to transfer, in Satoshis. May be negative." + required: true + type: "number" + format: "int64" + x-exportParamName: "Amount" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Position" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /position/leverage: + post: + tags: + - "Position" + summary: "Choose leverage for a position." + operationId: "Position.updateLeverage" + parameters: + - name: "symbol" + in: "formData" + description: "Symbol of position to adjust." + required: true + type: "string" + x-exportParamName: "Symbol" + - name: "leverage" + in: "formData" + description: "Leverage value. Send a number between 0.01 and 100 to enable\ + \ isolated margin with a fixed leverage. Send 0 to enable cross margin." + required: true + type: "number" + format: "double" + x-exportParamName: "Leverage" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Position" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + deprecated: false + /quote: + get: + tags: + - "Quote" + summary: "Get Quotes." + operationId: "Quote.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Quote" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /quote/bucketed: + get: + tags: + - "Quote" + summary: "Get previous quotes in time buckets." + operationId: "Quote.getBucketed" + parameters: + - name: "binSize" + in: "query" + description: "Time interval to bucket by. Available options: [1m,5m,1h,1d]." + required: false + type: "string" + default: "1m" + x-exportParamName: "BinSize" + x-optionalDataType: "String" + - name: "partial" + in: "query" + description: "If true, will send in-progress (incomplete) bins for the current\ + \ time period." + required: false + type: "boolean" + default: false + x-exportParamName: "Partial" + x-optionalDataType: "Bool" + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Quote" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /schema: + get: + tags: + - "Schema" + summary: "Get model schemata for data objects returned by this API." + operationId: "Schema.get" + parameters: + - name: "model" + in: "query" + description: "Optional model filter. If omitted, will return all models." + required: false + type: "string" + x-exportParamName: "Model" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "object" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /schema/websocketHelp: + get: + tags: + - "Schema" + summary: "Returns help text & subject list for websocket usage." + operationId: "Schema.websocketHelp" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "object" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /settlement: + get: + tags: + - "Settlement" + summary: "Get settlement history." + operationId: "Settlement.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Settlement" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /stats: + get: + tags: + - "Stats" + summary: "Get exchange-wide and per-series turnover and volume statistics." + operationId: "Stats.get" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Stats" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /stats/history: + get: + tags: + - "Stats" + summary: "Get historical exchange-wide and per-series turnover and volume statistics." + operationId: "Stats.history" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/StatsHistory" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /stats/historyUSD: + get: + tags: + - "Stats" + summary: "Get a summary of exchange statistics in USD." + operationId: "Stats.historyUSD" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/StatsUSD" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /trade: + get: + tags: + - "Trade" + summary: "Get Trades." + description: "Please note that indices (symbols starting with `.`) post trades\ + \ at intervals to the trade feed. These have a `size` of 0 and are used only\ + \ to indicate a changing price.\n\nSee [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_AE_6569.html)\ + \ for explanations of these fields." + operationId: "Trade.get" + parameters: + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Trade" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /trade/bucketed: + get: + tags: + - "Trade" + summary: "Get previous trades in time buckets." + operationId: "Trade.getBucketed" + parameters: + - name: "binSize" + in: "query" + description: "Time interval to bucket by. Available options: [1m,5m,1h,1d]." + required: false + type: "string" + default: "1m" + x-exportParamName: "BinSize" + x-optionalDataType: "String" + - name: "partial" + in: "query" + description: "If true, will send in-progress (incomplete) bins for the current\ + \ time period." + required: false + type: "boolean" + default: false + x-exportParamName: "Partial" + x-optionalDataType: "Bool" + - name: "symbol" + in: "query" + description: "Instrument symbol. Send a bare series (e.g. XBU) to get data\ + \ for the nearest expiring contract in that series.\n\nYou can also send\ + \ a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`,\ + \ `quarterly`, and `biquarterly`." + required: false + type: "string" + x-exportParamName: "Symbol" + x-optionalDataType: "String" + - name: "filter" + in: "query" + description: "Generic table filter. Send JSON key/value pairs, such as `{\"\ + key\": \"value\"}`. You can key on individual fields, and do more advanced\ + \ querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters)\ + \ for more details." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Filter" + x-optionalDataType: "String" + - name: "columns" + in: "query" + description: "Array of column names to fetch. If omitted, will return all\ + \ columns.\n\nNote that this method will always return item keys, even when\ + \ not specified, so you may receive more columns that you expect." + required: false + type: "string" + format: "JSON" + x-exportParamName: "Columns" + x-optionalDataType: "String" + - name: "count" + in: "query" + description: "Number of results to fetch." + required: false + type: "number" + default: 100.0 + format: "int32" + x-exportParamName: "Count" + x-optionalDataType: "Float32" + - name: "start" + in: "query" + description: "Starting point for results." + required: false + type: "number" + default: 0.0 + format: "int32" + x-exportParamName: "Start" + x-optionalDataType: "Float32" + - name: "reverse" + in: "query" + description: "If true, will sort results newest first." + required: false + type: "boolean" + default: false + x-exportParamName: "Reverse" + x-optionalDataType: "Bool" + - name: "startTime" + in: "query" + description: "Starting date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "StartTime" + x-optionalDataType: "Time" + - name: "endTime" + in: "query" + description: "Ending date filter for results." + required: false + type: "string" + format: "date-time" + x-exportParamName: "EndTime" + x-optionalDataType: "Time" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/TradeBin" + 400: + description: "Parameter Error" + schema: + $ref: "#/definitions/Error" + 401: + description: "Unauthorized" + schema: + $ref: "#/definitions/Error" + 404: + description: "Not Found" + schema: + $ref: "#/definitions/Error" + security: [] + deprecated: false + /user/depositAddress: + get: + tags: + - "User" + summary: "Get a deposit address." + operationId: "User.getDepositAddress" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "string" + deprecated: false + /user/wallet: + get: + tags: + - "User" + summary: "Get your current wallet information." + operationId: "User.getWallet" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Wallet" + deprecated: false + /user/walletHistory: + get: + tags: + - "User" + summary: "Get a history of all of your wallet transactions (deposits, withdrawals,\ + \ PNL)." + operationId: "User.getWalletHistory" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Transaction" + deprecated: false + /user/walletSummary: + get: + tags: + - "User" + summary: "Get a summary of all of your wallet transactions (deposits, withdrawals,\ + \ PNL)." + operationId: "User.getWalletSummary" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/Transaction" + deprecated: false + /user/minWithdrawalFee: + get: + tags: + - "User" + summary: "Get the minimum withdrawal fee for a currency." + description: "This is changed based on network conditions to ensure timely withdrawals.\ + \ During network congestion, this may be high. The fee is returned in the\ + \ same currency." + operationId: "User.minWithdrawalFee" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "object" + security: [] + deprecated: false + /user/requestWithdrawal: + post: + tags: + - "User" + summary: "Request a withdrawal to an external wallet." + description: "This will send a confirmation email to the email address on record,\ + \ unless requested via an API Key with the `withdraw` permission." + operationId: "User.requestWithdrawal" + parameters: + - name: "otpToken" + in: "formData" + description: "2FA token. Required if 2FA is enabled on your account." + required: false + type: "string" + x-exportParamName: "OtpToken" + x-optionalDataType: "String" + - name: "currency" + in: "formData" + description: "Currency you're withdrawing. Options: `XBt`" + required: true + type: "string" + default: "XBt" + x-exportParamName: "Currency" + - name: "amount" + in: "formData" + description: "Amount of withdrawal currency." + required: true + type: "number" + format: "int64" + x-exportParamName: "Amount" + - name: "address" + in: "formData" + description: "Destination Address." + required: true + type: "string" + x-exportParamName: "Address" + - name: "fee" + in: "formData" + description: "Network fee for Bitcoin withdrawals. If not specified, a default\ + \ value will be calculated based on Bitcoin network conditions. You will\ + \ have a chance to confirm this via email." + required: false + type: "number" + format: "double" + x-exportParamName: "Fee" + x-optionalDataType: "Float64" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Transaction" + deprecated: false + /user/cancelWithdrawal: + post: + tags: + - "User" + summary: "Cancel a withdrawal." + operationId: "User.cancelWithdrawal" + parameters: + - name: "token" + in: "formData" + required: true + type: "string" + x-exportParamName: "Token" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Transaction" + security: [] + deprecated: false + /user/confirmWithdrawal: + post: + tags: + - "User" + summary: "Confirm a withdrawal." + operationId: "User.confirmWithdrawal" + parameters: + - name: "token" + in: "formData" + required: true + type: "string" + x-exportParamName: "Token" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Transaction" + security: [] + deprecated: false + /user/requestEnableTFA: + post: + tags: + - "User" + summary: "Get secret key for setting up two-factor auth." + description: "Use /confirmEnableTFA directly for Yubikeys. This fails if TFA\ + \ is already enabled." + operationId: "User.requestEnableTFA" + parameters: + - name: "type" + in: "formData" + description: "Two-factor auth type. Supported types: 'GA' (Google Authenticator)" + required: false + type: "string" + x-exportParamName: "Type_" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "boolean" + deprecated: false + /user/confirmEnableTFA: + post: + tags: + - "User" + summary: "Confirm two-factor auth for this account. If using a Yubikey, simply\ + \ send a token to this endpoint." + operationId: "User.confirmEnableTFA" + parameters: + - name: "type" + in: "formData" + description: "Two-factor auth type. Supported types: 'GA' (Google Authenticator),\ + \ 'Yubikey'" + required: false + type: "string" + x-exportParamName: "Type_" + x-optionalDataType: "String" + - name: "token" + in: "formData" + description: "Token from your selected TFA type." + required: true + type: "string" + x-exportParamName: "Token" + responses: + 200: + description: "Request was successful" + schema: + type: "boolean" + deprecated: false + /user/disableTFA: + post: + tags: + - "User" + summary: "Disable two-factor auth for this account." + operationId: "User.disableTFA" + parameters: + - name: "type" + in: "formData" + description: "Two-factor auth type. Supported types: 'GA' (Google Authenticator)" + required: false + type: "string" + x-exportParamName: "Type_" + x-optionalDataType: "String" + - name: "token" + in: "formData" + description: "Token from your selected TFA type." + required: true + type: "string" + x-exportParamName: "Token" + responses: + 200: + description: "Request was successful" + schema: + type: "boolean" + deprecated: false + /user/confirmEmail: + post: + tags: + - "User" + summary: "Confirm your email address with a token." + operationId: "User.confirm" + parameters: + - name: "token" + in: "formData" + required: true + type: "string" + x-exportParamName: "Token" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/AccessToken" + security: [] + deprecated: false + /user/affiliateStatus: + get: + tags: + - "User" + summary: "Get your current affiliate/referral status." + operationId: "User.getAffiliateStatus" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Affiliate" + deprecated: false + /user/checkReferralCode: + get: + tags: + - "User" + summary: "Check if a referral code is valid." + description: "If the code is valid, responds with the referral code's discount\ + \ (e.g. `0.1` for 10%). Otherwise, will return a 404." + operationId: "User.checkReferralCode" + parameters: + - name: "referralCode" + in: "query" + required: false + type: "string" + x-exportParamName: "ReferralCode" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + type: "number" + format: "double" + security: [] + deprecated: false + /user/logout: + post: + tags: + - "User" + summary: "Log out of BitMEX." + operationId: "User.logout" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "null" + security: [] + deprecated: false + /user/logoutAll: + post: + tags: + - "User" + summary: "Log all systems out of BitMEX. This will revoke all of your account's\ + \ access tokens, logging you out on all devices." + operationId: "User.logoutAll" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "number" + format: "double" + deprecated: false + /user/preferences: + post: + tags: + - "User" + summary: "Save user preferences." + operationId: "User.savePreferences" + parameters: + - name: "prefs" + in: "formData" + required: true + type: "string" + format: "JSON" + x-exportParamName: "Prefs" + - name: "overwrite" + in: "formData" + description: "If true, will overwrite all existing preferences." + required: false + type: "boolean" + default: false + x-exportParamName: "Overwrite" + x-optionalDataType: "Bool" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/User" + deprecated: false + /user: + get: + tags: + - "User" + summary: "Get your user model." + operationId: "User.get" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/User" + deprecated: false + put: + tags: + - "User" + summary: "Update your password, name, and other attributes." + operationId: "User.update" + parameters: + - name: "firstname" + in: "formData" + required: false + type: "string" + x-exportParamName: "Firstname" + x-optionalDataType: "String" + - name: "lastname" + in: "formData" + required: false + type: "string" + x-exportParamName: "Lastname" + x-optionalDataType: "String" + - name: "oldPassword" + in: "formData" + required: false + type: "string" + x-exportParamName: "OldPassword" + x-optionalDataType: "String" + - name: "newPassword" + in: "formData" + required: false + type: "string" + x-exportParamName: "NewPassword" + x-optionalDataType: "String" + - name: "newPasswordConfirm" + in: "formData" + required: false + type: "string" + x-exportParamName: "NewPasswordConfirm" + x-optionalDataType: "String" + - name: "username" + in: "formData" + description: "Username can only be set once. To reset, email support." + required: false + type: "string" + x-exportParamName: "Username" + x-optionalDataType: "String" + - name: "country" + in: "formData" + description: "Country of residence." + required: false + type: "string" + x-exportParamName: "Country" + x-optionalDataType: "String" + - name: "pgpPubKey" + in: "formData" + description: "PGP Public Key. If specified, automated emails will be sentwith\ + \ this key." + required: false + type: "string" + x-exportParamName: "PgpPubKey" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/User" + deprecated: false + /user/commission: + get: + tags: + - "User" + summary: "Get your account's commission status." + operationId: "User.getCommission" + parameters: [] + responses: + 200: + description: "Request was successful" + schema: + type: "array" + items: + $ref: "#/definitions/UserCommission" + deprecated: false + /user/margin: + get: + tags: + - "User" + summary: "Get your account's margin status. Send a currency of \"all\" to receive\ + \ an array of all supported currencies." + operationId: "User.getMargin" + parameters: + - name: "currency" + in: "query" + required: false + type: "string" + default: "XBt" + x-exportParamName: "Currency" + x-optionalDataType: "String" + responses: + 200: + description: "Request was successful" + schema: + $ref: "#/definitions/Margin" + deprecated: false +securityDefinitions: + apiKey: + type: "apiKey" + name: "api-key" + in: "header" + apiSignature: + type: "apiKey" + name: "api-signature" + in: "header" + apiNonce: + type: "apiKey" + name: "api-nonce" + in: "header" +definitions: + Announcement: + type: "object" + required: + - "id" + properties: + id: + type: "number" + format: "int32" + link: + type: "string" + title: + type: "string" + content: + type: "string" + date: + type: "string" + format: "date-time" + description: "Public Announcements" + example: + date: "2000-01-23T04:56:07.000+00:00" + link: "link" + id: 0.80082819046101150206595775671303272247314453125 + title: "title" + content: "content" + Error: + type: "object" + required: + - "error" + properties: + error: + $ref: "#/definitions/Error_error" + x-any: + type: "object" + APIKey: + type: "object" + required: + - "id" + - "name" + - "nonce" + - "secret" + - "userId" + properties: + id: + type: "string" + maxLength: 24 + secret: + type: "string" + maxLength: 48 + name: + type: "string" + maxLength: 64 + nonce: + type: "number" + format: "int64" + cidr: + type: "string" + maxLength: 18 + permissions: + type: "array" + items: + $ref: "#/definitions/x-any" + enabled: + type: "boolean" + default: false + userId: + type: "number" + format: "int32" + created: + type: "string" + format: "date-time" + description: "Persistent API Keys for Developers" + example: + permissions: + - {} + - {} + created: "2000-01-23T04:56:07.000+00:00" + name: "name" + cidr: "cidr" + id: "id" + secret: "secret" + nonce: 0.80082819046101150206595775671303272247314453125 + userId: 6.02745618307040320615897144307382404804229736328125 + enabled: false + Chat: + type: "object" + required: + - "date" + - "html" + - "message" + - "user" + properties: + id: + type: "number" + format: "int32" + date: + type: "string" + format: "date-time" + user: + type: "string" + message: + type: "string" + html: + type: "string" + fromBot: + type: "boolean" + default: false + channelID: + type: "number" + format: "double" + description: "Trollbox Data" + example: + date: "2000-01-23T04:56:07.000+00:00" + html: "html" + id: 0.80082819046101150206595775671303272247314453125 + message: "message" + user: "user" + channelID: 6.027456183070403 + fromBot: false + ChatChannel: + type: "object" + required: + - "name" + properties: + id: + type: "number" + format: "int32" + name: + type: "string" + example: + name: "name" + id: 0.80082819046101150206595775671303272247314453125 + ConnectedUsers: + type: "object" + properties: + users: + type: "number" + format: "int32" + bots: + type: "number" + format: "int32" + example: + bots: 6.02745618307040320615897144307382404804229736328125 + users: 0.80082819046101150206595775671303272247314453125 + Execution: + type: "object" + required: + - "execID" + properties: + execID: + type: "string" + format: "guid" + orderID: + type: "string" + format: "guid" + clOrdID: + type: "string" + clOrdLinkID: + type: "string" + account: + type: "number" + format: "int64" + symbol: + type: "string" + side: + type: "string" + lastQty: + type: "number" + format: "int64" + lastPx: + type: "number" + format: "double" + underlyingLastPx: + type: "number" + format: "double" + lastMkt: + type: "string" + lastLiquidityInd: + type: "string" + simpleOrderQty: + type: "number" + format: "double" + orderQty: + type: "number" + format: "int64" + price: + type: "number" + format: "double" + displayQty: + type: "number" + format: "int64" + stopPx: + type: "number" + format: "double" + pegOffsetValue: + type: "number" + format: "double" + pegPriceType: + type: "string" + currency: + type: "string" + settlCurrency: + type: "string" + execType: + type: "string" + ordType: + type: "string" + timeInForce: + type: "string" + execInst: + type: "string" + contingencyType: + type: "string" + exDestination: + type: "string" + ordStatus: + type: "string" + triggered: + type: "string" + workingIndicator: + type: "boolean" + ordRejReason: + type: "string" + simpleLeavesQty: + type: "number" + format: "double" + leavesQty: + type: "number" + format: "int64" + simpleCumQty: + type: "number" + format: "double" + cumQty: + type: "number" + format: "int64" + avgPx: + type: "number" + format: "double" + commission: + type: "number" + format: "double" + tradePublishIndicator: + type: "string" + multiLegReportingType: + type: "string" + text: + type: "string" + trdMatchID: + type: "string" + format: "guid" + execCost: + type: "number" + format: "int64" + execComm: + type: "number" + format: "int64" + homeNotional: + type: "number" + format: "double" + foreignNotional: + type: "number" + format: "double" + transactTime: + type: "string" + format: "date-time" + timestamp: + type: "string" + format: "date-time" + description: "Raw Order and Balance Data" + example: + symbol: "symbol" + triggered: "triggered" + clOrdLinkID: "clOrdLinkID" + execInst: "execInst" + homeNotional: 4.965218492984954 + pegOffsetValue: 2.027123023002322 + pegPriceType: "pegPriceType" + execID: "execID" + contingencyType: "contingencyType" + foreignNotional: 5.025004791520295 + lastMkt: "lastMkt" + simpleCumQty: 1.2315135367772556 + execCost: 7.4577447736837658709418974467553198337554931640625 + execComm: 1.173074250955943309548956676735542714595794677734375 + settlCurrency: "settlCurrency" + ordRejReason: "ordRejReason" + price: 7.061401241503109 + trdMatchID: "trdMatchID" + orderQty: 2.3021358869347654518833223846741020679473876953125 + currency: "currency" + commission: 6.84685269835264 + text: "text" + execType: "execType" + timeInForce: "timeInForce" + timestamp: "2000-01-23T04:56:07.000+00:00" + ordStatus: "ordStatus" + side: "side" + simpleOrderQty: 5.637376656633329 + orderID: "orderID" + lastPx: 1.4658129805029452 + leavesQty: 7.3862819483858839220147274318151175975799560546875 + cumQty: 1.024645700144157789424070870154537260532379150390625 + tradePublishIndicator: "tradePublishIndicator" + displayQty: 9.301444243932575517419536481611430644989013671875 + simpleLeavesQty: 4.145608029883936 + clOrdID: "clOrdID" + lastQty: 6.02745618307040320615897144307382404804229736328125 + avgPx: 1.4894159098541704 + multiLegReportingType: "multiLegReportingType" + workingIndicator: true + lastLiquidityInd: "lastLiquidityInd" + transactTime: "2000-01-23T04:56:07.000+00:00" + exDestination: "exDestination" + account: 0.80082819046101150206595775671303272247314453125 + underlyingLastPx: 5.962133916683182 + stopPx: 3.616076749251911 + ordType: "ordType" + Funding: + type: "object" + required: + - "symbol" + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + fundingInterval: + type: "string" + format: "date-time" + fundingRate: + type: "number" + format: "double" + fundingRateDaily: + type: "number" + format: "double" + description: "Swap Funding History" + example: + symbol: "symbol" + fundingRateDaily: 6.027456183070403 + fundingInterval: "2000-01-23T04:56:07.000+00:00" + timestamp: "2000-01-23T04:56:07.000+00:00" + fundingRate: 0.8008281904610115 + Instrument: + type: "object" + required: + - "symbol" + properties: + symbol: + type: "string" + rootSymbol: + type: "string" + state: + type: "string" + typ: + type: "string" + listing: + type: "string" + format: "date-time" + front: + type: "string" + format: "date-time" + expiry: + type: "string" + format: "date-time" + settle: + type: "string" + format: "date-time" + relistInterval: + type: "string" + format: "date-time" + inverseLeg: + type: "string" + sellLeg: + type: "string" + buyLeg: + type: "string" + optionStrikePcnt: + type: "number" + format: "double" + optionStrikeRound: + type: "number" + format: "double" + optionStrikePrice: + type: "number" + format: "double" + optionMultiplier: + type: "number" + format: "double" + positionCurrency: + type: "string" + underlying: + type: "string" + quoteCurrency: + type: "string" + underlyingSymbol: + type: "string" + reference: + type: "string" + referenceSymbol: + type: "string" + calcInterval: + type: "string" + format: "date-time" + publishInterval: + type: "string" + format: "date-time" + publishTime: + type: "string" + format: "date-time" + maxOrderQty: + type: "number" + format: "int64" + maxPrice: + type: "number" + format: "double" + lotSize: + type: "number" + format: "int64" + tickSize: + type: "number" + format: "double" + multiplier: + type: "number" + format: "int64" + settlCurrency: + type: "string" + underlyingToPositionMultiplier: + type: "number" + format: "int64" + underlyingToSettleMultiplier: + type: "number" + format: "int64" + quoteToSettleMultiplier: + type: "number" + format: "int64" + isQuanto: + type: "boolean" + isInverse: + type: "boolean" + initMargin: + type: "number" + format: "double" + maintMargin: + type: "number" + format: "double" + riskLimit: + type: "number" + format: "int64" + riskStep: + type: "number" + format: "int64" + limit: + type: "number" + format: "double" + capped: + type: "boolean" + taxed: + type: "boolean" + deleverage: + type: "boolean" + makerFee: + type: "number" + format: "double" + takerFee: + type: "number" + format: "double" + settlementFee: + type: "number" + format: "double" + insuranceFee: + type: "number" + format: "double" + fundingBaseSymbol: + type: "string" + fundingQuoteSymbol: + type: "string" + fundingPremiumSymbol: + type: "string" + fundingTimestamp: + type: "string" + format: "date-time" + fundingInterval: + type: "string" + format: "date-time" + fundingRate: + type: "number" + format: "double" + indicativeFundingRate: + type: "number" + format: "double" + rebalanceTimestamp: + type: "string" + format: "date-time" + rebalanceInterval: + type: "string" + format: "date-time" + openingTimestamp: + type: "string" + format: "date-time" + closingTimestamp: + type: "string" + format: "date-time" + sessionInterval: + type: "string" + format: "date-time" + prevClosePrice: + type: "number" + format: "double" + limitDownPrice: + type: "number" + format: "double" + limitUpPrice: + type: "number" + format: "double" + bankruptLimitDownPrice: + type: "number" + format: "double" + bankruptLimitUpPrice: + type: "number" + format: "double" + prevTotalVolume: + type: "number" + format: "int64" + totalVolume: + type: "number" + format: "int64" + volume: + type: "number" + format: "int64" + volume24h: + type: "number" + format: "int64" + prevTotalTurnover: + type: "number" + format: "int64" + totalTurnover: + type: "number" + format: "int64" + turnover: + type: "number" + format: "int64" + turnover24h: + type: "number" + format: "int64" + prevPrice24h: + type: "number" + format: "double" + vwap: + type: "number" + format: "double" + highPrice: + type: "number" + format: "double" + lowPrice: + type: "number" + format: "double" + lastPrice: + type: "number" + format: "double" + lastPriceProtected: + type: "number" + format: "double" + lastTickDirection: + type: "string" + lastChangePcnt: + type: "number" + format: "double" + bidPrice: + type: "number" + format: "double" + midPrice: + type: "number" + format: "double" + askPrice: + type: "number" + format: "double" + impactBidPrice: + type: "number" + format: "double" + impactMidPrice: + type: "number" + format: "double" + impactAskPrice: + type: "number" + format: "double" + hasLiquidity: + type: "boolean" + openInterest: + type: "number" + format: "int64" + openValue: + type: "number" + format: "int64" + fairMethod: + type: "string" + fairBasisRate: + type: "number" + format: "double" + fairBasis: + type: "number" + format: "double" + fairPrice: + type: "number" + format: "double" + markMethod: + type: "string" + markPrice: + type: "number" + format: "double" + indicativeTaxRate: + type: "number" + format: "double" + indicativeSettlePrice: + type: "number" + format: "double" + optionUnderlyingPrice: + type: "number" + format: "double" + settledPrice: + type: "number" + format: "double" + timestamp: + type: "string" + format: "date-time" + description: "Tradeable Contracts, Indices, and History" + example: + optionUnderlyingPrice: 0.8774076871421566 + deleverage: true + riskLimit: 1.489415909854170383397331534069962799549102783203125 + fundingBaseSymbol: "fundingBaseSymbol" + prevPrice24h: 7.143538047012306 + highPrice: 7.058770351582356 + fairMethod: "fairMethod" + taxed: true + state: "state" + expiry: "2000-01-23T04:56:07.000+00:00" + fundingPremiumSymbol: "fundingPremiumSymbol" + publishInterval: "2000-01-23T04:56:07.000+00:00" + publishTime: "2000-01-23T04:56:07.000+00:00" + maintMargin: 1.0246457001441578 + takerFee: 4.965218492984954 + fairBasis: 4.258773108174356 + volume24h: 6.87805222012787620400331434211693704128265380859375 + underlying: "underlying" + quoteToSettleMultiplier: 7.3862819483858839220147274318151175975799560546875 + fundingQuoteSymbol: "fundingQuoteSymbol" + quoteCurrency: "quoteCurrency" + indicativeSettlePrice: 9.132027271330688 + settledPrice: 9.702963800023566 + relistInterval: "2000-01-23T04:56:07.000+00:00" + prevClosePrice: 8.762042012749001 + maxPrice: 2.3021358869347655 + underlyingToPositionMultiplier: 2.027123023002321833274663731572218239307403564453125 + settle: "2000-01-23T04:56:07.000+00:00" + buyLeg: "buyLeg" + tickSize: 9.301444243932576 + markPrice: 4.678947989005849 + settlCurrency: "settlCurrency" + listing: "2000-01-23T04:56:07.000+00:00" + indicativeFundingRate: 6.683562403749608 + positionCurrency: "positionCurrency" + timestamp: "2000-01-23T04:56:07.000+00:00" + limitDownPrice: 9.018348186070783 + lastTickDirection: "lastTickDirection" + rebalanceTimestamp: "2000-01-23T04:56:07.000+00:00" + fairBasisRate: 6.628464275087742 + lastPriceProtected: 4.652396432933246 + midPrice: 3.0205796992916243 + insuranceFee: 9.965781217890562 + optionStrikePrice: 1.4658129805029452 + limitUpPrice: 6.438423552598547 + bankruptLimitUpPrice: 6.965117697638846 + rebalanceInterval: "2000-01-23T04:56:07.000+00:00" + fundingRate: 9.369310271410669 + lastPrice: 0.10263654006109402 + totalVolume: 2.884162126668780246063761296682059764862060546875 + symbol: "symbol" + capped: true + vwap: 0.8851374739011653 + closingTimestamp: "2000-01-23T04:56:07.000+00:00" + typ: "typ" + inverseLeg: "inverseLeg" + reference: "reference" + prevTotalTurnover: 5.94489560761401580890606055618263781070709228515625 + limit: 7.457744773683766 + calcInterval: "2000-01-23T04:56:07.000+00:00" + lastChangePcnt: 8.969578798196912 + askPrice: 3.0576100241049344 + multiplier: 3.61607674925191080461672754609026014804840087890625 + indicativeTaxRate: 7.260521264802104 + settlementFee: 5.025004791520295 + totalTurnover: 6.70401929795003592715829654480330646038055419921875 + turnover24h: 3.093745262666447448651751983561553061008453369140625 + fairPrice: 1.041444916118296 + bidPrice: 7.740351818741173 + volume: 6.77832496304801335185175048536621034145355224609375 + impactMidPrice: 5.533258397034986 + sellLeg: "sellLeg" + optionStrikePcnt: 0.8008281904610115 + maxOrderQty: 5.63737665663332876420099637471139430999755859375 + hasLiquidity: true + openInterest: 4.078845849666752343409825698472559452056884765625 + riskStep: 6.8468526983526398765889098285697400569915771484375 + optionStrikeRound: 6.027456183070403 + isQuanto: true + rootSymbol: "rootSymbol" + markMethod: "markMethod" + underlyingSymbol: "underlyingSymbol" + fundingTimestamp: "2000-01-23T04:56:07.000+00:00" + makerFee: 1.1730742509559433 + lowPrice: 6.519180951018382 + underlyingToSettleMultiplier: 4.1456080298839363962315474054776132106781005859375 + sessionInterval: "2000-01-23T04:56:07.000+00:00" + fundingInterval: "2000-01-23T04:56:07.000+00:00" + bankruptLimitDownPrice: 3.5571952270680973 + turnover: 3.35319334701124294184637619764544069766998291015625 + impactAskPrice: 3.2588565619047607 + referenceSymbol: "referenceSymbol" + openValue: 0.202532411323639305322785730822943150997161865234375 + isInverse: true + lotSize: 7.061401241503109105224211816675961017608642578125 + optionMultiplier: 5.962133916683182 + openingTimestamp: "2000-01-23T04:56:07.000+00:00" + impactBidPrice: 7.04836565559697 + prevTotalVolume: 1.2846590061165319429647979632136411964893341064453125 + initMargin: 1.2315135367772556 + front: "2000-01-23T04:56:07.000+00:00" + InstrumentInterval: + type: "object" + required: + - "intervals" + - "symbols" + properties: + intervals: + type: "array" + items: + type: "string" + symbols: + type: "array" + items: + type: "string" + example: + intervals: + - "intervals" + - "intervals" + symbols: + - "symbols" + - "symbols" + IndexComposite: + type: "object" + required: + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + indexSymbol: + type: "string" + reference: + type: "string" + lastPrice: + type: "number" + format: "double" + weight: + type: "number" + format: "double" + logged: + type: "string" + format: "date-time" + example: + reference: "reference" + symbol: "symbol" + indexSymbol: "indexSymbol" + logged: "2000-01-23T04:56:07.000+00:00" + weight: 6.027456183070403 + timestamp: "2000-01-23T04:56:07.000+00:00" + lastPrice: 0.8008281904610115 + Insurance: + type: "object" + required: + - "currency" + - "timestamp" + properties: + currency: + type: "string" + timestamp: + type: "string" + format: "date-time" + walletBalance: + type: "number" + format: "int64" + description: "Insurance Fund Data" + example: + walletBalance: 0.80082819046101150206595775671303272247314453125 + currency: "currency" + timestamp: "2000-01-23T04:56:07.000+00:00" + Leaderboard: + type: "object" + required: + - "name" + properties: + name: + type: "string" + isRealName: + type: "boolean" + profit: + type: "number" + format: "double" + description: "Information on Top Users" + example: + name: "name" + isRealName: true + profit: 0.8008281904610115 + Liquidation: + type: "object" + required: + - "orderID" + properties: + orderID: + type: "string" + format: "guid" + symbol: + type: "string" + side: + type: "string" + price: + type: "number" + format: "double" + leavesQty: + type: "number" + format: "int64" + description: "Active Liquidations" + example: + symbol: "symbol" + side: "side" + orderID: "orderID" + price: 0.8008281904610115 + leavesQty: 6.02745618307040320615897144307382404804229736328125 + Notification: + type: "object" + required: + - "body" + - "date" + - "title" + - "ttl" + properties: + id: + type: "number" + format: "int32" + date: + type: "string" + format: "date-time" + title: + type: "string" + body: + type: "string" + ttl: + type: "number" + format: "int32" + type: + type: "string" + enum: + - "success" + - "error" + - "info" + closable: + type: "boolean" + default: true + persist: + type: "boolean" + default: true + waitForVisibility: + type: "boolean" + default: true + sound: + type: "string" + description: "Account Notifications" + example: + date: "2000-01-23T04:56:07.000+00:00" + waitForVisibility: true + closable: true + sound: "sound" + id: 0.80082819046101150206595775671303272247314453125 + persist: true + title: "title" + body: "body" + type: "success" + ttl: 6.02745618307040320615897144307382404804229736328125 + Order: + type: "object" + required: + - "orderID" + properties: + orderID: + type: "string" + format: "guid" + clOrdID: + type: "string" + clOrdLinkID: + type: "string" + account: + type: "number" + format: "int64" + symbol: + type: "string" + side: + type: "string" + simpleOrderQty: + type: "number" + format: "double" + orderQty: + type: "number" + format: "int64" + price: + type: "number" + format: "double" + displayQty: + type: "number" + format: "int64" + stopPx: + type: "number" + format: "double" + pegOffsetValue: + type: "number" + format: "double" + pegPriceType: + type: "string" + currency: + type: "string" + settlCurrency: + type: "string" + ordType: + type: "string" + timeInForce: + type: "string" + execInst: + type: "string" + contingencyType: + type: "string" + exDestination: + type: "string" + ordStatus: + type: "string" + triggered: + type: "string" + workingIndicator: + type: "boolean" + ordRejReason: + type: "string" + simpleLeavesQty: + type: "number" + format: "double" + leavesQty: + type: "number" + format: "int64" + simpleCumQty: + type: "number" + format: "double" + cumQty: + type: "number" + format: "int64" + avgPx: + type: "number" + format: "double" + multiLegReportingType: + type: "string" + text: + type: "string" + transactTime: + type: "string" + format: "date-time" + timestamp: + type: "string" + format: "date-time" + description: "Placement, Cancellation, Amending, and History" + example: + symbol: "symbol" + triggered: "triggered" + clOrdLinkID: "clOrdLinkID" + execInst: "execInst" + pegOffsetValue: 7.061401241503109 + pegPriceType: "pegPriceType" + contingencyType: "contingencyType" + simpleCumQty: 2.027123023002322 + settlCurrency: "settlCurrency" + ordRejReason: "ordRejReason" + price: 5.962133916683182 + orderQty: 1.46581298050294517310021547018550336360931396484375 + currency: "currency" + text: "text" + timeInForce: "timeInForce" + timestamp: "2000-01-23T04:56:07.000+00:00" + ordStatus: "ordStatus" + side: "side" + simpleOrderQty: 6.027456183070403 + orderID: "orderID" + leavesQty: 3.61607674925191080461672754609026014804840087890625 + cumQty: 4.1456080298839363962315474054776132106781005859375 + displayQty: 5.63737665663332876420099637471139430999755859375 + simpleLeavesQty: 9.301444243932576 + clOrdID: "clOrdID" + avgPx: 7.386281948385884 + multiLegReportingType: "multiLegReportingType" + workingIndicator: true + transactTime: "2000-01-23T04:56:07.000+00:00" + exDestination: "exDestination" + account: 0.80082819046101150206595775671303272247314453125 + stopPx: 2.3021358869347655 + ordType: "ordType" + OrderBookL2: + type: "object" + required: + - "id" + - "side" + - "symbol" + properties: + symbol: + type: "string" + id: + type: "number" + format: "int64" + side: + type: "string" + size: + type: "number" + format: "int64" + price: + type: "number" + format: "double" + example: + symbol: "symbol" + side: "side" + size: 6.02745618307040320615897144307382404804229736328125 + price: 1.4658129805029452 + id: 0.80082819046101150206595775671303272247314453125 + Position: + type: "object" + required: + - "account" + - "currency" + - "symbol" + properties: + account: + type: "number" + format: "int64" + symbol: + type: "string" + currency: + type: "string" + underlying: + type: "string" + quoteCurrency: + type: "string" + commission: + type: "number" + format: "double" + default: 0.0 + initMarginReq: + type: "number" + format: "double" + default: 0.0 + maintMarginReq: + type: "number" + format: "double" + default: 0.0 + riskLimit: + type: "number" + format: "int64" + leverage: + type: "number" + format: "double" + default: 0.0 + crossMargin: + type: "boolean" + deleveragePercentile: + type: "number" + format: "double" + default: 0.0 + rebalancedPnl: + type: "number" + format: "int64" + prevRealisedPnl: + type: "number" + format: "int64" + prevUnrealisedPnl: + type: "number" + format: "int64" + prevClosePrice: + type: "number" + format: "double" + default: 0.0 + openingTimestamp: + type: "string" + format: "date-time" + openingQty: + type: "number" + format: "int64" + openingCost: + type: "number" + format: "int64" + openingComm: + type: "number" + format: "int64" + openOrderBuyQty: + type: "number" + format: "int64" + openOrderBuyCost: + type: "number" + format: "int64" + openOrderBuyPremium: + type: "number" + format: "int64" + openOrderSellQty: + type: "number" + format: "int64" + openOrderSellCost: + type: "number" + format: "int64" + openOrderSellPremium: + type: "number" + format: "int64" + execBuyQty: + type: "number" + format: "int64" + execBuyCost: + type: "number" + format: "int64" + execSellQty: + type: "number" + format: "int64" + execSellCost: + type: "number" + format: "int64" + execQty: + type: "number" + format: "int64" + execCost: + type: "number" + format: "int64" + execComm: + type: "number" + format: "int64" + currentTimestamp: + type: "string" + format: "date-time" + currentQty: + type: "number" + format: "int64" + currentCost: + type: "number" + format: "int64" + currentComm: + type: "number" + format: "int64" + realisedCost: + type: "number" + format: "int64" + unrealisedCost: + type: "number" + format: "int64" + grossOpenCost: + type: "number" + format: "int64" + grossOpenPremium: + type: "number" + format: "int64" + grossExecCost: + type: "number" + format: "int64" + isOpen: + type: "boolean" + markPrice: + type: "number" + format: "double" + default: 0.0 + markValue: + type: "number" + format: "int64" + riskValue: + type: "number" + format: "int64" + homeNotional: + type: "number" + format: "double" + default: 0.0 + foreignNotional: + type: "number" + format: "double" + default: 0.0 + posState: + type: "string" + posCost: + type: "number" + format: "int64" + posCost2: + type: "number" + format: "int64" + posCross: + type: "number" + format: "int64" + posInit: + type: "number" + format: "int64" + posComm: + type: "number" + format: "int64" + posLoss: + type: "number" + format: "int64" + posMargin: + type: "number" + format: "int64" + posMaint: + type: "number" + format: "int64" + posAllowance: + type: "number" + format: "int64" + taxableMargin: + type: "number" + format: "int64" + initMargin: + type: "number" + format: "int64" + maintMargin: + type: "number" + format: "int64" + sessionMargin: + type: "number" + format: "int64" + targetExcessMargin: + type: "number" + format: "int64" + varMargin: + type: "number" + format: "int64" + realisedGrossPnl: + type: "number" + format: "int64" + realisedTax: + type: "number" + format: "int64" + realisedPnl: + type: "number" + format: "int64" + unrealisedGrossPnl: + type: "number" + format: "int64" + longBankrupt: + type: "number" + format: "int64" + shortBankrupt: + type: "number" + format: "int64" + taxBase: + type: "number" + format: "int64" + indicativeTaxRate: + type: "number" + format: "double" + default: 0.0 + indicativeTax: + type: "number" + format: "int64" + unrealisedTax: + type: "number" + format: "int64" + unrealisedPnl: + type: "number" + format: "int64" + unrealisedPnlPcnt: + type: "number" + format: "double" + default: 0.0 + unrealisedRoePcnt: + type: "number" + format: "double" + default: 0.0 + simpleQty: + type: "number" + format: "double" + default: 0.0 + simpleCost: + type: "number" + format: "double" + default: 0.0 + simpleValue: + type: "number" + format: "double" + default: 0.0 + simplePnl: + type: "number" + format: "double" + default: 0.0 + simplePnlPcnt: + type: "number" + format: "double" + default: 0.0 + avgCostPrice: + type: "number" + format: "double" + default: 0.0 + avgEntryPrice: + type: "number" + format: "double" + default: 0.0 + breakEvenPrice: + type: "number" + format: "double" + default: 0.0 + marginCallPrice: + type: "number" + format: "double" + default: 0.0 + liquidationPrice: + type: "number" + format: "double" + default: 0.0 + bankruptPrice: + type: "number" + format: "double" + default: 0.0 + timestamp: + type: "string" + format: "date-time" + lastPrice: + type: "number" + format: "double" + default: 0.0 + lastValue: + type: "number" + format: "int64" + description: "Summary of Open and Closed Positions" + example: + symbol: "symbol" + lastValue: 5.2991435602753593769875806174241006374359130859375 + breakEvenPrice: 1.8268702177058116 + avgCostPrice: 8.863729185622827 + posLoss: 3.05761002410493443193217899533919990062713623046875 + openOrderSellQty: 1.173074250955943309548956676735542714595794677734375 + avgEntryPrice: 9.254183946267839 + taxBase: 5.5073869641798811613853104063309729099273681640625 + foreignNotional: 6.519180951018382 + execComm: 3.557195227068097320710649000830017030239105224609375 + riskLimit: 5.63737665663332876420099637471139430999755859375 + prevUnrealisedPnl: 2.027123023002321833274663731572218239307403564453125 + longBankrupt: 0.519900201872498524124921459588222205638885498046875 + marginCallPrice: 3.502657762086401 + unrealisedCost: 6.87805222012787620400331434211693704128265380859375 + posComm: 3.02057969929162428712743349024094641208648681640625 + posMaint: 5.5332583970349862312332334113307297229766845703125 + simplePnlPcnt: 4.573936264232251 + execSellCost: 8.7620420127490010742121739895083010196685791015625 + realisedCost: 6.77832496304801335185175048536621034145355224609375 + posInit: 7.7403518187411730622216055053286254405975341796875 + grossExecCost: 3.35319334701124294184637619764544069766998291015625 + posAllowance: 3.258856561904760695824734284542500972747802734375 + targetExcessMargin: 1.0414449161182959269211778519093059003353118896484375 + shortBankrupt: 7.93350688173715123951978966942988336086273193359375 + indicativeTax: 6.07389808578115175663469926803372800350189208984375 + maintMargin: 6.6284642750877420525057459599338471889495849609375 + riskValue: 0.885137473901165261480628032586537301540374755859375 + execBuyCost: 9.3693102714106686335071572102606296539306640625 + grossOpenPremium: 6.70401929795003592715829654480330646038055419921875 + currentCost: 1.2846590061165319429647979632136411964893341064453125 + indicativeTaxRate: 4.86315908102884 + underlying: "underlying" + quoteCurrency: "quoteCurrency" + initMarginReq: 1.4658129805029452 + isOpen: true + posCross: 8.9695787981969115065794539987109601497650146484375 + currentTimestamp: "2000-01-23T04:56:07.000+00:00" + simpleValue: 8.28965939814297 + prevClosePrice: 4.145608029883936 + unrealisedPnlPcnt: 3.901545264248647 + simpleCost: 1.7325933120207193 + execQty: 9.0183481860707832566959041287191212177276611328125 + taxableMargin: 4.078845849666752343409825698472559452056884765625 + openingCost: 1.231513536777255612975068288506008684635162353515625 + realisedGrossPnl: 7.26052126480210358039357743109576404094696044921875 + leverage: 2.3021358869347655 + posState: "posState" + openOrderSellPremium: 5.02500479152029466689555192715488374233245849609375 + simpleQty: 2.9409642974827896 + openingQty: 7.3862819483858839220147274318151175975799560546875 + homeNotional: 7.058770351582356 + liquidationPrice: 9.183123594773994 + openOrderBuyQty: 1.489415909854170383397331534069962799549102783203125 + unrealisedPnl: 4.4596050349586793259959449642337858676910400390625 + execCost: 6.438423552598546706349225132726132869720458984375 + unrealisedGrossPnl: 9.7029638000235660655334868351928889751434326171875 + markPrice: 3.0937452626664474 + posMargin: 7.04836565559697003635619694250635802745819091796875 + unrealisedTax: 8.2516257489237574418439180590212345123291015625 + crossMargin: true + deleveragePercentile: 7.061401241503109 + openOrderBuyCost: 6.8468526983526398765889098285697400569915771484375 + posCost: 0.10263654006109401706225980888120830059051513671875 + currency: "currency" + commission: 6.027456183070403 + sessionMargin: 4.258773108174356281097061582840979099273681640625 + maintMarginReq: 5.962133916683182 + bankruptPrice: 8.761432466225475 + openOrderSellCost: 4.9652184929849543237878606305457651615142822265625 + markValue: 7.14353804701230643559028976596891880035400390625 + timestamp: "2000-01-23T04:56:07.000+00:00" + realisedPnl: 0.8774076871421565559927557842456735670566558837890625 + varMargin: 4.67894798900584873990737833082675933837890625 + realisedTax: 9.132027271330688478201409452594816684722900390625 + rebalancedPnl: 9.301444243932575517419536481611430644989013671875 + openOrderBuyPremium: 7.4577447736837658709418974467553198337554931640625 + posCost2: 4.6523964329332461176136348512955009937286376953125 + openingTimestamp: "2000-01-23T04:56:07.000+00:00" + currentQty: 6.96511769763884558415156789124011993408203125 + currentComm: 2.884162126668780246063761296682059764862060546875 + execSellQty: 6.683562403749608193948006373830139636993408203125 + grossOpenCost: 5.94489560761401580890606055618263781070709228515625 + prevRealisedPnl: 3.61607674925191080461672754609026014804840087890625 + execBuyQty: 9.965781217890562260208753286860883235931396484375 + initMargin: 0.202532411323639305322785730822943150997161865234375 + unrealisedRoePcnt: 0.43431398824148815 + simplePnl: 6.623518433804886 + account: 0.80082819046101150206595775671303272247314453125 + openingComm: 1.024645700144157789424070870154537260532379150390625 + lastPrice: 0.4182561061793122 + Quote: + type: "object" + required: + - "symbol" + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + bidSize: + type: "number" + format: "int64" + bidPrice: + type: "number" + format: "double" + askPrice: + type: "number" + format: "double" + askSize: + type: "number" + format: "int64" + description: "Best Bid/Offer Snapshots & Historical Bins" + example: + symbol: "symbol" + askPrice: 1.4658129805029452 + bidSize: 0.80082819046101150206595775671303272247314453125 + bidPrice: 6.027456183070403 + askSize: 5.962133916683182377482808078639209270477294921875 + timestamp: "2000-01-23T04:56:07.000+00:00" + Settlement: + type: "object" + required: + - "symbol" + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + settlementType: + type: "string" + settledPrice: + type: "number" + format: "double" + optionStrikePrice: + type: "number" + format: "double" + optionUnderlyingPrice: + type: "number" + format: "double" + bankrupt: + type: "number" + format: "int64" + taxBase: + type: "number" + format: "int64" + taxRate: + type: "number" + format: "double" + description: "Historical Settlement Data" + example: + settlementType: "settlementType" + symbol: "symbol" + taxRate: 2.3021358869347655 + optionStrikePrice: 6.027456183070403 + settledPrice: 0.8008281904610115 + optionUnderlyingPrice: 1.4658129805029452 + bankrupt: 5.962133916683182377482808078639209270477294921875 + timestamp: "2000-01-23T04:56:07.000+00:00" + taxBase: 5.63737665663332876420099637471139430999755859375 + Stats: + type: "object" + required: + - "rootSymbol" + properties: + rootSymbol: + type: "string" + currency: + type: "string" + volume24h: + type: "number" + format: "int64" + turnover24h: + type: "number" + format: "int64" + openInterest: + type: "number" + format: "int64" + openValue: + type: "number" + format: "int64" + description: "Exchange Statistics" + example: + openInterest: 1.46581298050294517310021547018550336360931396484375 + openValue: 5.962133916683182377482808078639209270477294921875 + volume24h: 0.80082819046101150206595775671303272247314453125 + currency: "currency" + turnover24h: 6.02745618307040320615897144307382404804229736328125 + rootSymbol: "rootSymbol" + StatsHistory: + type: "object" + required: + - "date" + - "rootSymbol" + properties: + date: + type: "string" + format: "date-time" + rootSymbol: + type: "string" + currency: + type: "string" + volume: + type: "number" + format: "int64" + turnover: + type: "number" + format: "int64" + example: + date: "2000-01-23T04:56:07.000+00:00" + volume: 0.80082819046101150206595775671303272247314453125 + currency: "currency" + turnover: 6.02745618307040320615897144307382404804229736328125 + rootSymbol: "rootSymbol" + StatsUSD: + type: "object" + required: + - "rootSymbol" + properties: + rootSymbol: + type: "string" + currency: + type: "string" + turnover24h: + type: "number" + format: "int64" + turnover30d: + type: "number" + format: "int64" + turnover365d: + type: "number" + format: "int64" + turnover: + type: "number" + format: "int64" + example: + turnover30d: 6.02745618307040320615897144307382404804229736328125 + turnover365d: 1.46581298050294517310021547018550336360931396484375 + currency: "currency" + turnover24h: 0.80082819046101150206595775671303272247314453125 + turnover: 5.962133916683182377482808078639209270477294921875 + rootSymbol: "rootSymbol" + Trade: + type: "object" + required: + - "symbol" + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + side: + type: "string" + size: + type: "number" + format: "int64" + price: + type: "number" + format: "double" + tickDirection: + type: "string" + trdMatchID: + type: "string" + format: "guid" + grossValue: + type: "number" + format: "int64" + homeNotional: + type: "number" + format: "double" + foreignNotional: + type: "number" + format: "double" + description: "Individual & Bucketed Trades" + example: + foreignNotional: 5.637376656633329 + symbol: "symbol" + side: "side" + tickDirection: "tickDirection" + size: 0.80082819046101150206595775671303272247314453125 + price: 6.027456183070403 + grossValue: 1.46581298050294517310021547018550336360931396484375 + trdMatchID: "trdMatchID" + homeNotional: 5.962133916683182 + timestamp: "2000-01-23T04:56:07.000+00:00" + TradeBin: + type: "object" + required: + - "symbol" + - "timestamp" + properties: + timestamp: + type: "string" + format: "date-time" + symbol: + type: "string" + open: + type: "number" + format: "double" + high: + type: "number" + format: "double" + low: + type: "number" + format: "double" + close: + type: "number" + format: "double" + trades: + type: "number" + format: "int64" + volume: + type: "number" + format: "int64" + vwap: + type: "number" + format: "double" + lastSize: + type: "number" + format: "int64" + turnover: + type: "number" + format: "int64" + homeNotional: + type: "number" + format: "double" + foreignNotional: + type: "number" + format: "double" + example: + symbol: "symbol" + vwap: 7.061401241503109 + trades: 5.63737665663332876420099637471139430999755859375 + homeNotional: 2.027123023002322 + volume: 2.3021358869347654518833223846741020679473876953125 + foreignNotional: 4.145608029883936 + high: 6.027456183070403 + low: 1.4658129805029452 + lastSize: 9.301444243932575517419536481611430644989013671875 + close: 5.962133916683182 + turnover: 3.61607674925191080461672754609026014804840087890625 + open: 0.8008281904610115 + timestamp: "2000-01-23T04:56:07.000+00:00" + Wallet: + type: "object" + required: + - "account" + - "currency" + properties: + account: + type: "number" + format: "int64" + currency: + type: "string" + prevDeposited: + type: "number" + format: "int64" + prevWithdrawn: + type: "number" + format: "int64" + prevTransferIn: + type: "number" + format: "int64" + prevTransferOut: + type: "number" + format: "int64" + prevAmount: + type: "number" + format: "int64" + prevTimestamp: + type: "string" + format: "date-time" + deltaDeposited: + type: "number" + format: "int64" + deltaWithdrawn: + type: "number" + format: "int64" + deltaTransferIn: + type: "number" + format: "int64" + deltaTransferOut: + type: "number" + format: "int64" + deltaAmount: + type: "number" + format: "int64" + deposited: + type: "number" + format: "int64" + withdrawn: + type: "number" + format: "int64" + transferIn: + type: "number" + format: "int64" + transferOut: + type: "number" + format: "int64" + amount: + type: "number" + format: "int64" + pendingCredit: + type: "number" + format: "int64" + pendingDebit: + type: "number" + format: "int64" + confirmedDebit: + type: "number" + format: "int64" + timestamp: + type: "string" + format: "date-time" + addr: + type: "string" + script: + type: "string" + withdrawalLock: + type: "array" + items: + type: "string" + example: + deposited: 7.3862819483858839220147274318151175975799560546875 + withdrawn: 1.231513536777255612975068288506008684635162353515625 + deltaDeposited: 7.061401241503109105224211816675961017608642578125 + prevWithdrawn: 1.46581298050294517310021547018550336360931396484375 + deltaWithdrawn: 9.301444243932575517419536481611430644989013671875 + currency: "currency" + prevAmount: 2.3021358869347654518833223846741020679473876953125 + withdrawalLock: + - "withdrawalLock" + - "withdrawalLock" + addr: "addr" + prevTimestamp: "2000-01-23T04:56:07.000+00:00" + timestamp: "2000-01-23T04:56:07.000+00:00" + transferOut: 1.489415909854170383397331534069962799549102783203125 + deltaAmount: 4.1456080298839363962315474054776132106781005859375 + amount: 6.8468526983526398765889098285697400569915771484375 + pendingDebit: 1.173074250955943309548956676735542714595794677734375 + confirmedDebit: 4.9652184929849543237878606305457651615142822265625 + pendingCredit: 7.4577447736837658709418974467553198337554931640625 + script: "script" + prevTransferOut: 5.63737665663332876420099637471139430999755859375 + deltaTransferOut: 2.027123023002321833274663731572218239307403564453125 + deltaTransferIn: 3.61607674925191080461672754609026014804840087890625 + transferIn: 1.024645700144157789424070870154537260532379150390625 + prevDeposited: 6.02745618307040320615897144307382404804229736328125 + prevTransferIn: 5.962133916683182377482808078639209270477294921875 + account: 0.80082819046101150206595775671303272247314453125 + Transaction: + type: "object" + required: + - "transactID" + properties: + transactID: + type: "string" + format: "guid" + account: + type: "number" + format: "int64" + currency: + type: "string" + transactType: + type: "string" + amount: + type: "number" + format: "int64" + fee: + type: "number" + format: "int64" + transactStatus: + type: "string" + address: + type: "string" + tx: + type: "string" + text: + type: "string" + transactTime: + type: "string" + format: "date-time" + timestamp: + type: "string" + format: "date-time" + example: + amount: 6.02745618307040320615897144307382404804229736328125 + address: "address" + transactType: "transactType" + tx: "tx" + transactID: "transactID" + fee: 1.46581298050294517310021547018550336360931396484375 + transactTime: "2000-01-23T04:56:07.000+00:00" + currency: "currency" + text: "text" + account: 0.80082819046101150206595775671303272247314453125 + transactStatus: "transactStatus" + timestamp: "2000-01-23T04:56:07.000+00:00" + AccessToken: + type: "object" + required: + - "id" + properties: + id: + type: "string" + ttl: + type: "number" + format: "double" + description: "time to live in seconds (2 weeks by default)" + default: 1209600.0 + created: + type: "string" + format: "date-time" + userId: + type: "number" + format: "double" + example: + created: "2000-01-23T04:56:07.000+00:00" + id: "id" + ttl: 0.8008281904610115 + userId: 6.027456183070403 + Affiliate: + type: "object" + required: + - "account" + - "currency" + properties: + account: + type: "number" + format: "int64" + currency: + type: "string" + prevPayout: + type: "number" + format: "int64" + prevTurnover: + type: "number" + format: "int64" + prevComm: + type: "number" + format: "int64" + prevTimestamp: + type: "string" + format: "date-time" + execTurnover: + type: "number" + format: "int64" + execComm: + type: "number" + format: "int64" + totalReferrals: + type: "number" + format: "int64" + totalTurnover: + type: "number" + format: "int64" + totalComm: + type: "number" + format: "int64" + payoutPcnt: + type: "number" + format: "double" + pendingPayout: + type: "number" + format: "int64" + timestamp: + type: "string" + format: "date-time" + referrerAccount: + type: "number" + format: "double" + example: + execTurnover: 5.63737665663332876420099637471139430999755859375 + totalTurnover: 9.301444243932575517419536481611430644989013671875 + referrerAccount: 7.386281948385884 + execComm: 2.3021358869347654518833223846741020679473876953125 + totalReferrals: 7.061401241503109105224211816675961017608642578125 + currency: "currency" + pendingPayout: 4.1456080298839363962315474054776132106781005859375 + prevPayout: 6.02745618307040320615897144307382404804229736328125 + prevComm: 5.962133916683182377482808078639209270477294921875 + prevTimestamp: "2000-01-23T04:56:07.000+00:00" + account: 0.80082819046101150206595775671303272247314453125 + prevTurnover: 1.46581298050294517310021547018550336360931396484375 + totalComm: 3.61607674925191080461672754609026014804840087890625 + payoutPcnt: 2.027123023002322 + timestamp: "2000-01-23T04:56:07.000+00:00" + User: + type: "object" + required: + - "email" + - "username" + properties: + id: + type: "number" + format: "int32" + ownerId: + type: "number" + format: "int32" + firstname: + type: "string" + lastname: + type: "string" + username: + type: "string" + email: + type: "string" + phone: + type: "string" + created: + type: "string" + format: "date-time" + lastUpdated: + type: "string" + format: "date-time" + preferences: + $ref: "#/definitions/UserPreferences" + TFAEnabled: + type: "string" + affiliateID: + type: "string" + maxLength: 6 + pgpPubKey: + type: "string" + maxLength: 16384 + country: + type: "string" + maxLength: 3 + geoipCountry: + type: "string" + maxLength: 2 + geoipRegion: + type: "string" + maxLength: 2 + typ: + type: "string" + description: "Account Operations" + example: + geoipRegion: "geoipRegion" + country: "country" + firstname: "firstname" + preferences: + hideNotifications: + - "hideNotifications" + - "hideNotifications" + tickerGroup: "tickerGroup" + animationsEnabled: true + alertOnLiquidations: true + locale: "en-US" + hideConfirmDialogs: + - "hideConfirmDialogs" + - "hideConfirmDialogs" + disableEmails: + - "disableEmails" + - "disableEmails" + sounds: + - "sounds" + - "sounds" + colorTheme: "colorTheme" + currency: "currency" + hideNameFromLeaderboard: true + tradeLayout: "tradeLayout" + strictTimeout: true + orderBookBinning: "{}" + debug: true + strictIPCheck: false + msgsSeen: + - "msgsSeen" + - "msgsSeen" + orderControlsPlusMinus: true + hideConnectionModal: true + tickerPinned: true + hideFromLeaderboard: false + announcementsLastSeen: "2000-01-23T04:56:07.000+00:00" + orderBookType: "orderBookType" + orderClearImmediate: false + showLocaleNumbers: true + chatChannelID: 1.4658129805029452 + created: "2000-01-23T04:56:07.000+00:00" + typ: "typ" + ownerId: 6.02745618307040320615897144307382404804229736328125 + affiliateID: "affiliateID" + lastname: "lastname" + geoipCountry: "geoipCountry" + lastUpdated: "2000-01-23T04:56:07.000+00:00" + phone: "phone" + TFAEnabled: "TFAEnabled" + id: 0.80082819046101150206595775671303272247314453125 + email: "email" + pgpPubKey: "pgpPubKey" + username: "username" + UserCommission: + type: "object" + properties: + makerFee: + type: "number" + format: "double" + takerFee: + type: "number" + format: "double" + settlementFee: + type: "number" + format: "double" + maxFee: + type: "number" + format: "double" + example: + takerFee: 6.027456183070403 + makerFee: 0.8008281904610115 + settlementFee: 1.4658129805029452 + maxFee: 5.962133916683182 + Margin: + type: "object" + required: + - "account" + - "currency" + properties: + account: + type: "number" + format: "int64" + currency: + type: "string" + riskLimit: + type: "number" + format: "int64" + prevState: + type: "string" + state: + type: "string" + action: + type: "string" + amount: + type: "number" + format: "int64" + pendingCredit: + type: "number" + format: "int64" + pendingDebit: + type: "number" + format: "int64" + confirmedDebit: + type: "number" + format: "int64" + prevRealisedPnl: + type: "number" + format: "int64" + prevUnrealisedPnl: + type: "number" + format: "int64" + grossComm: + type: "number" + format: "int64" + grossOpenCost: + type: "number" + format: "int64" + grossOpenPremium: + type: "number" + format: "int64" + grossExecCost: + type: "number" + format: "int64" + grossMarkValue: + type: "number" + format: "int64" + riskValue: + type: "number" + format: "int64" + taxableMargin: + type: "number" + format: "int64" + initMargin: + type: "number" + format: "int64" + maintMargin: + type: "number" + format: "int64" + sessionMargin: + type: "number" + format: "int64" + targetExcessMargin: + type: "number" + format: "int64" + varMargin: + type: "number" + format: "int64" + realisedPnl: + type: "number" + format: "int64" + unrealisedPnl: + type: "number" + format: "int64" + indicativeTax: + type: "number" + format: "int64" + unrealisedProfit: + type: "number" + format: "int64" + syntheticMargin: + type: "number" + format: "int64" + walletBalance: + type: "number" + format: "int64" + marginBalance: + type: "number" + format: "int64" + marginBalancePcnt: + type: "number" + format: "double" + default: 0.0 + marginLeverage: + type: "number" + format: "double" + default: 0.0 + marginUsedPcnt: + type: "number" + format: "double" + default: 0.0 + excessMargin: + type: "number" + format: "int64" + excessMarginPcnt: + type: "number" + format: "double" + default: 0.0 + availableMargin: + type: "number" + format: "int64" + withdrawableMargin: + type: "number" + format: "int64" + timestamp: + type: "string" + format: "date-time" + grossLastValue: + type: "number" + format: "int64" + commission: + type: "number" + format: "double" + default: 0.0 + example: + grossMarkValue: 1.231513536777255612975068288506008684635162353515625 + marginUsedPcnt: 2.8841621266687802 + marginLeverage: 1.284659006116532 + marginBalancePcnt: 6.965117697638846 + unrealisedPnl: 9.3693102714106686335071572102606296539306640625 + riskLimit: 6.02745618307040320615897144307382404804229736328125 + prevUnrealisedPnl: 9.301444243932575517419536481611430644989013671875 + walletBalance: 6.438423552598546706349225132726132869720458984375 + grossLastValue: 3.35319334701124294184637619764544069766998291015625 + action: "action" + currency: "currency" + commission: 3.0937452626664474 + state: "state" + sessionMargin: 1.173074250955943309548956676735542714595794677734375 + marginBalance: 3.557195227068097320710649000830017030239105224609375 + timestamp: "2000-01-23T04:56:07.000+00:00" + grossExecCost: 7.3862819483858839220147274318151175975799560546875 + targetExcessMargin: 4.9652184929849543237878606305457651615142822265625 + realisedPnl: 9.965781217890562260208753286860883235931396484375 + varMargin: 5.02500479152029466689555192715488374233245849609375 + indicativeTax: 6.683562403749608193948006373830139636993408203125 + amount: 1.46581298050294517310021547018550336360931396484375 + maintMargin: 7.4577447736837658709418974467553198337554931640625 + pendingDebit: 5.63737665663332876420099637471139430999755859375 + riskValue: 1.024645700144157789424070870154537260532379150390625 + confirmedDebit: 2.3021358869347654518833223846741020679473876953125 + grossComm: 3.61607674925191080461672754609026014804840087890625 + grossOpenPremium: 4.1456080298839363962315474054776132106781005859375 + excessMarginPcnt: 6.878052220127876 + withdrawableMargin: 6.70401929795003592715829654480330646038055419921875 + pendingCredit: 5.962133916683182377482808078639209270477294921875 + grossOpenCost: 2.027123023002321833274663731572218239307403564453125 + prevState: "prevState" + prevRealisedPnl: 7.061401241503109105224211816675961017608642578125 + excessMargin: 6.77832496304801335185175048536621034145355224609375 + unrealisedProfit: 8.7620420127490010742121739895083010196685791015625 + initMargin: 6.8468526983526398765889098285697400569915771484375 + syntheticMargin: 9.0183481860707832566959041287191212177276611328125 + taxableMargin: 1.489415909854170383397331534069962799549102783203125 + account: 0.80082819046101150206595775671303272247314453125 + availableMargin: 5.94489560761401580890606055618263781070709228515625 + UserPreferences: + type: "object" + properties: + alertOnLiquidations: + type: "boolean" + animationsEnabled: + type: "boolean" + announcementsLastSeen: + type: "string" + format: "date-time" + chatChannelID: + type: "number" + format: "double" + colorTheme: + type: "string" + currency: + type: "string" + debug: + type: "boolean" + disableEmails: + type: "array" + items: + type: "string" + hideConfirmDialogs: + type: "array" + items: + type: "string" + hideConnectionModal: + type: "boolean" + hideFromLeaderboard: + type: "boolean" + default: false + hideNameFromLeaderboard: + type: "boolean" + default: true + hideNotifications: + type: "array" + items: + type: "string" + locale: + type: "string" + default: "en-US" + msgsSeen: + type: "array" + items: + type: "string" + orderBookBinning: + type: "object" + properties: {} + orderBookType: + type: "string" + orderClearImmediate: + type: "boolean" + default: false + orderControlsPlusMinus: + type: "boolean" + showLocaleNumbers: + type: "boolean" + default: true + sounds: + type: "array" + items: + type: "string" + strictIPCheck: + type: "boolean" + default: false + strictTimeout: + type: "boolean" + default: true + tickerGroup: + type: "string" + tickerPinned: + type: "boolean" + tradeLayout: + type: "string" + example: + hideNotifications: + - "hideNotifications" + - "hideNotifications" + tickerGroup: "tickerGroup" + animationsEnabled: true + alertOnLiquidations: true + locale: "en-US" + hideConfirmDialogs: + - "hideConfirmDialogs" + - "hideConfirmDialogs" + disableEmails: + - "disableEmails" + - "disableEmails" + sounds: + - "sounds" + - "sounds" + colorTheme: "colorTheme" + currency: "currency" + hideNameFromLeaderboard: true + tradeLayout: "tradeLayout" + strictTimeout: true + orderBookBinning: "{}" + debug: true + strictIPCheck: false + msgsSeen: + - "msgsSeen" + - "msgsSeen" + orderControlsPlusMinus: true + hideConnectionModal: true + tickerPinned: true + hideFromLeaderboard: false + announcementsLastSeen: "2000-01-23T04:56:07.000+00:00" + orderBookType: "orderBookType" + orderClearImmediate: false + showLocaleNumbers: true + chatChannelID: 1.4658129805029452 + inline_response_200: + properties: + success: + type: "boolean" + example: + success: true + inline_response_200_1: + properties: + name: + type: "string" + example: + name: "name" + Error_error: + properties: + message: + type: "string" + name: + type: "string" diff --git a/api_announcement.go b/api_announcement.go new file mode 100644 index 0000000..5804ba5 --- /dev/null +++ b/api_announcement.go @@ -0,0 +1,314 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type AnnouncementApiService service + +/* +AnnouncementApiService Get site announcements. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *AnnouncementGetOpts - Optional Parameters: + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. + +@return []Announcement +*/ + +type AnnouncementGetOpts struct { + Columns optional.String +} + +func (a *AnnouncementApiService) AnnouncementGet(ctx context.Context, localVarOptionals *AnnouncementGetOpts) ([]Announcement, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Announcement + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/announcement" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Announcement + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +AnnouncementApiService Get urgent (banner) announcements. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Announcement +*/ +func (a *AnnouncementApiService) AnnouncementGetUrgent(ctx context.Context) ([]Announcement, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Announcement + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/announcement/urgent" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Announcement + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_api_key.go b/api_api_key.go new file mode 100644 index 0000000..fc82020 --- /dev/null +++ b/api_api_key.go @@ -0,0 +1,864 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type APIKeyApiService service + +/* +APIKeyApiService Disable an API Key. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param apiKeyID API Key ID (public component). + +@return ApiKey +*/ +func (a *APIKeyApiService) APIKeyDisable(ctx context.Context, apiKeyID string) (ApiKey, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ApiKey + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/apiKey/disable" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("apiKeyID", parameterToString(apiKeyID, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ApiKey + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +APIKeyApiService Enable an API Key. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param apiKeyID API Key ID (public component). + +@return ApiKey +*/ +func (a *APIKeyApiService) APIKeyEnable(ctx context.Context, apiKeyID string) (ApiKey, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ApiKey + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/apiKey/enable" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("apiKeyID", parameterToString(apiKeyID, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ApiKey + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +APIKeyApiService Get your API Keys. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *APIKeyGetOpts - Optional Parameters: + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + +@return []ApiKey +*/ + +type APIKeyGetOpts struct { + Reverse optional.Bool +} + +func (a *APIKeyApiService) APIKeyGet(ctx context.Context, localVarOptionals *APIKeyGetOpts) ([]ApiKey, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []ApiKey + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/apiKey" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []ApiKey + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +APIKeyApiService Create a new API Key. +API Keys can only be created via the frontend. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *APIKeyNewOpts - Optional Parameters: + * @param "Name" (optional.String) - Key name. This name is for reference only. + * @param "Cidr" (optional.String) - CIDR block to restrict this key to. To restrict to a single address, append \"/32\", e.g. 207.39.29.22/32. Leave blank or set to 0.0.0.0/0 to allow all IPs. Only one block may be set. <a href=\"http://software77.net/cidr-101.html\">More on CIDR blocks</a> + * @param "Permissions" (optional.String) - Key Permissions. All keys can read margin and position data. Additional permissions must be added. Available: [\"order\", \"orderCancel\", \"withdraw\"]. + * @param "Enabled" (optional.Bool) - Set to true to enable this key on creation. Otherwise, it must be explicitly enabled via /apiKey/enable. + * @param "Token" (optional.String) - OTP Token (YubiKey, Google Authenticator) + +@return ApiKey +*/ + +type APIKeyNewOpts struct { + Name optional.String + Cidr optional.String + Permissions optional.String + Enabled optional.Bool + Token optional.String +} + +func (a *APIKeyApiService) APIKeyNew(ctx context.Context, localVarOptionals *APIKeyNewOpts) (ApiKey, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ApiKey + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/apiKey" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Name.IsSet() { + localVarFormParams.Add("name", parameterToString(localVarOptionals.Name.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Cidr.IsSet() { + localVarFormParams.Add("cidr", parameterToString(localVarOptionals.Cidr.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Permissions.IsSet() { + localVarFormParams.Add("permissions", parameterToString(localVarOptionals.Permissions.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Enabled.IsSet() { + localVarFormParams.Add("enabled", parameterToString(localVarOptionals.Enabled.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Token.IsSet() { + localVarFormParams.Add("token", parameterToString(localVarOptionals.Token.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ApiKey + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +APIKeyApiService Remove an API Key. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param apiKeyID API Key ID (public component). + +@return InlineResponse200 +*/ +func (a *APIKeyApiService) APIKeyRemove(ctx context.Context, apiKeyID string) (InlineResponse200, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue InlineResponse200 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/apiKey" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("apiKeyID", parameterToString(apiKeyID, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v InlineResponse200 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_chat.go b/api_chat.go new file mode 100644 index 0000000..57bf0cb --- /dev/null +++ b/api_chat.go @@ -0,0 +1,580 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type ChatApiService service + +/* +ChatApiService Get chat messages. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *ChatGetOpts - Optional Parameters: + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting ID for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "ChannelID" (optional.Float64) - Channel id. GET /chat/channels for ids. Leave blank for all. + +@return []Chat +*/ + +type ChatGetOpts struct { + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + ChannelID optional.Float64 +} + +func (a *ChatApiService) ChatGet(ctx context.Context, localVarOptionals *ChatGetOpts) ([]Chat, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Chat + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/chat" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ChannelID.IsSet() { + localVarQueryParams.Add("channelID", parameterToString(localVarOptionals.ChannelID.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Chat + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ChatApiService Get available channels. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []ChatChannel +*/ +func (a *ChatApiService) ChatGetChannels(ctx context.Context) ([]ChatChannel, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []ChatChannel + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/chat/channels" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []ChatChannel + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ChatApiService Get connected users. +Returns an array with browser users in the first position and API users (bots) in the second position. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return ConnectedUsers +*/ +func (a *ChatApiService) ChatGetConnected(ctx context.Context) (ConnectedUsers, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue ConnectedUsers + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/chat/connected" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ConnectedUsers + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ChatApiService Send a chat message. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param message + * @param optional nil or *ChatNewOpts - Optional Parameters: + * @param "ChannelID" (optional.Float64) - Channel to post to. Default 1 (English). + +@return Chat +*/ + +type ChatNewOpts struct { + ChannelID optional.Float64 +} + +func (a *ChatApiService) ChatNew(ctx context.Context, message string, localVarOptionals *ChatNewOpts) (Chat, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Chat + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/chat" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("message", parameterToString(message, "")) + if localVarOptionals != nil && localVarOptionals.ChannelID.IsSet() { + localVarFormParams.Add("channelID", parameterToString(localVarOptionals.ChannelID.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Chat + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_execution.go b/api_execution.go new file mode 100644 index 0000000..62b125f --- /dev/null +++ b/api_execution.go @@ -0,0 +1,434 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type ExecutionApiService service + +/* +ExecutionApiService Get all raw executions for your account. +This returns all raw transactions, which includes order opening and cancelation, and order status changes. It can be quite noisy. More focused information is available at `/execution/tradeHistory`. You may also use the `filter` param to target your query. Specify an array as a filter value, such as `{\"execType\": [\"Settlement\", \"Trade\"]}` to filter on multiple values. See [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_8_8.html) for explanations of these fields. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *ExecutionGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Execution +*/ + +type ExecutionGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *ExecutionApiService) ExecutionGet(ctx context.Context, localVarOptionals *ExecutionGetOpts) ([]Execution, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Execution + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/execution" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Execution + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ExecutionApiService Get all balance-affecting executions. This includes each trade, insurance charge, and settlement. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *ExecutionGetTradeHistoryOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Execution +*/ + +type ExecutionGetTradeHistoryOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *ExecutionApiService) ExecutionGetTradeHistory(ctx context.Context, localVarOptionals *ExecutionGetTradeHistoryOpts) ([]Execution, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Execution + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/execution/tradeHistory" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Execution + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_funding.go b/api_funding.go new file mode 100644 index 0000000..90d45f3 --- /dev/null +++ b/api_funding.go @@ -0,0 +1,191 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type FundingApiService service + +/* +FundingApiService Get funding history. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FundingGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Funding +*/ + +type FundingGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *FundingApiService) FundingGet(ctx context.Context, localVarOptionals *FundingGetOpts) ([]Funding, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Funding + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/funding" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Funding + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_instrument.go b/api_instrument.go new file mode 100644 index 0000000..ec8d520 --- /dev/null +++ b/api_instrument.go @@ -0,0 +1,839 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type InstrumentApiService service + +/* +InstrumentApiService Get instruments. +This returns all instruments and indices, including those that have settled or are unlisted. Use this endpoint if you want to query for individual instruments or use a complex filter. Use `/instrument/active` to return active instruments, or use a filter like `{\"state\": \"Open\"}`. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *InstrumentGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Instrument +*/ + +type InstrumentGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *InstrumentApiService) InstrumentGet(ctx context.Context, localVarOptionals *InstrumentGetOpts) ([]Instrument, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Instrument + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Instrument + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +InstrumentApiService Get all active instruments and instruments that have expired in <24hrs. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Instrument +*/ +func (a *InstrumentApiService) InstrumentGetActive(ctx context.Context) ([]Instrument, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Instrument + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument/active" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Instrument + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +InstrumentApiService Helper method. Gets all active instruments and all indices. This is a join of the result of /indices and /active. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Instrument +*/ +func (a *InstrumentApiService) InstrumentGetActiveAndIndices(ctx context.Context) ([]Instrument, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Instrument + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument/activeAndIndices" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Instrument + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +InstrumentApiService Return all active contract series and interval pairs. +This endpoint is useful for determining which pairs are live. It returns two arrays of strings. The first is intervals, such as `[\"XBT:perpetual\", \"XBT:monthly\", \"XBT:quarterly\", \"ETH:monthly\", ...]`. These identifiers are usable in any query's `symbol` param. The second array is the current resolution of these intervals. Results are mapped at the same index. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return InstrumentInterval +*/ +func (a *InstrumentApiService) InstrumentGetActiveIntervals(ctx context.Context) (InstrumentInterval, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue InstrumentInterval + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument/activeIntervals" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v InstrumentInterval + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +InstrumentApiService Show constituent parts of an index. +Composite indices are built from multiple external price sources. Use this endpoint to get the underlying prices of an index. For example, send a `symbol` of `.XBT` to get the ticks and weights of the constituent exchanges that build the \".XBT\" index. A tick with reference `\"BMI\"` and weight `null` is the composite index tick. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *InstrumentGetCompositeIndexOpts - Optional Parameters: + * @param "Account" (optional.Float64) - + * @param "Symbol" (optional.String) - The composite index symbol. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []IndexComposite +*/ + +type InstrumentGetCompositeIndexOpts struct { + Account optional.Float64 + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *InstrumentApiService) InstrumentGetCompositeIndex(ctx context.Context, localVarOptionals *InstrumentGetCompositeIndexOpts) ([]IndexComposite, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []IndexComposite + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument/compositeIndex" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []IndexComposite + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +InstrumentApiService Get all price indices. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Instrument +*/ +func (a *InstrumentApiService) InstrumentGetIndices(ctx context.Context) ([]Instrument, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Instrument + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/instrument/indices" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Instrument + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_insurance.go b/api_insurance.go new file mode 100644 index 0000000..66b0ae2 --- /dev/null +++ b/api_insurance.go @@ -0,0 +1,191 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type InsuranceApiService service + +/* +InsuranceApiService Get insurance fund history. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *InsuranceGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Insurance +*/ + +type InsuranceGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *InsuranceApiService) InsuranceGet(ctx context.Context, localVarOptionals *InsuranceGetOpts) ([]Insurance, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Insurance + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/insurance" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Insurance + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_leaderboard.go b/api_leaderboard.go new file mode 100644 index 0000000..1c5aea4 --- /dev/null +++ b/api_leaderboard.go @@ -0,0 +1,314 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type LeaderboardApiService service + +/* +LeaderboardApiService Get current leaderboard. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *LeaderboardGetOpts - Optional Parameters: + * @param "Method" (optional.String) - Ranking type. Options: \"notional\", \"ROE\" + +@return []Leaderboard +*/ + +type LeaderboardGetOpts struct { + Method optional.String +} + +func (a *LeaderboardApiService) LeaderboardGet(ctx context.Context, localVarOptionals *LeaderboardGetOpts) ([]Leaderboard, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Leaderboard + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/leaderboard" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Method.IsSet() { + localVarQueryParams.Add("method", parameterToString(localVarOptionals.Method.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Leaderboard + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +LeaderboardApiService Get your alias on the leaderboard. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return InlineResponse2001 +*/ +func (a *LeaderboardApiService) LeaderboardGetName(ctx context.Context) (InlineResponse2001, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue InlineResponse2001 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/leaderboard/name" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v InlineResponse2001 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_liquidation.go b/api_liquidation.go new file mode 100644 index 0000000..c578349 --- /dev/null +++ b/api_liquidation.go @@ -0,0 +1,191 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type LiquidationApiService service + +/* +LiquidationApiService Get liquidation orders. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *LiquidationGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Liquidation +*/ + +type LiquidationGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *LiquidationApiService) LiquidationGet(ctx context.Context, localVarOptionals *LiquidationGetOpts) ([]Liquidation, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Liquidation + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/liquidation" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Liquidation + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_notification.go b/api_notification.go new file mode 100644 index 0000000..936108e --- /dev/null +++ b/api_notification.go @@ -0,0 +1,185 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +// Linger please +var ( + _ context.Context +) + +type NotificationApiService service + +/* +NotificationApiService Get your current notifications. +This is an upcoming feature and currently does not return data. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Notification +*/ +func (a *NotificationApiService) NotificationGet(ctx context.Context) ([]Notification, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Notification + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/notification" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Notification + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_order.go b/api_order.go new file mode 100644 index 0000000..01c7441 --- /dev/null +++ b/api_order.go @@ -0,0 +1,1718 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type OrderApiService service + +/* +OrderApiService Amend the quantity or price of an open order. +Send an `orderID` or `origClOrdID` to identify the order you wish to amend. Both order quantity and price can be amended. Only one `qty` field can be used to amend. Use the `leavesQty` field to specify how much of the order you wish to remain open. This can be useful if you want to adjust your position's delta by a certain amount, regardless of how much of the order has already filled. > A `leavesQty` can be used to make a \"Filled\" order live again, if it is received within 60 seconds of the fill. Use the `simpleOrderQty` and `simpleLeavesQty` fields to specify order size in Bitcoin, rather than contracts. These fields will round up to the nearest contract. Like order placement, amending can be done in bulk. Simply send a request to `PUT /api/v1/order/bulk` with a JSON body of the shape: `{\"orders\": [{...}, {...}]}`, each object containing the fields used in this endpoint. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderAmendOpts - Optional Parameters: + * @param "OrderID" (optional.String) - Order ID + * @param "OrigClOrdID" (optional.String) - Client Order ID. See POST /order. + * @param "ClOrdID" (optional.String) - Optional new Client Order ID, requires `origClOrdID`. + * @param "SimpleOrderQty" (optional.Float64) - Optional order quantity in units of the underlying instrument (i.e. Bitcoin). + * @param "OrderQty" (optional.Float32) - Optional order quantity in units of the instrument (i.e. contracts). + * @param "SimpleLeavesQty" (optional.Float64) - Optional leaves quantity in units of the underlying instrument (i.e. Bitcoin). Useful for amending partially filled orders. + * @param "LeavesQty" (optional.Float32) - Optional leaves quantity in units of the instrument (i.e. contracts). Useful for amending partially filled orders. + * @param "Price" (optional.Float64) - Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched' orders. + * @param "StopPx" (optional.Float64) - Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. Use a price below the current price for stop-sell orders and buy-if-touched orders. + * @param "PegOffsetValue" (optional.Float64) - Optional trailing offset from the current price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative offset for stop-sell orders and buy-if-touched orders. Optional offset from the peg price for 'Pegged' orders. + * @param "Text" (optional.String) - Optional amend annotation. e.g. 'Adjust skew'. + +@return Order +*/ + +type OrderAmendOpts struct { + OrderID optional.String + OrigClOrdID optional.String + ClOrdID optional.String + SimpleOrderQty optional.Float64 + OrderQty optional.Float32 + SimpleLeavesQty optional.Float64 + LeavesQty optional.Float32 + Price optional.Float64 + StopPx optional.Float64 + PegOffsetValue optional.Float64 + Text optional.String +} + +func (a *OrderApiService) OrderAmend(ctx context.Context, localVarOptionals *OrderAmendOpts) (Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.OrderID.IsSet() { + localVarFormParams.Add("orderID", parameterToString(localVarOptionals.OrderID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OrigClOrdID.IsSet() { + localVarFormParams.Add("origClOrdID", parameterToString(localVarOptionals.OrigClOrdID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ClOrdID.IsSet() { + localVarFormParams.Add("clOrdID", parameterToString(localVarOptionals.ClOrdID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SimpleOrderQty.IsSet() { + localVarFormParams.Add("simpleOrderQty", parameterToString(localVarOptionals.SimpleOrderQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OrderQty.IsSet() { + localVarFormParams.Add("orderQty", parameterToString(localVarOptionals.OrderQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SimpleLeavesQty.IsSet() { + localVarFormParams.Add("simpleLeavesQty", parameterToString(localVarOptionals.SimpleLeavesQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.LeavesQty.IsSet() { + localVarFormParams.Add("leavesQty", parameterToString(localVarOptionals.LeavesQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Price.IsSet() { + localVarFormParams.Add("price", parameterToString(localVarOptionals.Price.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StopPx.IsSet() { + localVarFormParams.Add("stopPx", parameterToString(localVarOptionals.StopPx.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PegOffsetValue.IsSet() { + localVarFormParams.Add("pegOffsetValue", parameterToString(localVarOptionals.PegOffsetValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Text.IsSet() { + localVarFormParams.Add("text", parameterToString(localVarOptionals.Text.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Amend multiple orders for the same symbol. +Similar to POST /amend, but with multiple orders. `application/json` only. Ratelimited at 10%. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderAmendBulkOpts - Optional Parameters: + * @param "Orders" (optional.String) - An array of orders. + +@return []Order +*/ + +type OrderAmendBulkOpts struct { + Orders optional.String +} + +func (a *OrderApiService) OrderAmendBulk(ctx context.Context, localVarOptionals *OrderAmendBulkOpts) ([]Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order/bulk" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Orders.IsSet() { + localVarFormParams.Add("orders", parameterToString(localVarOptionals.Orders.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Cancel order(s). Send multiple order IDs to cancel in bulk. +Either an orderID or a clOrdID must be provided. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderCancelOpts - Optional Parameters: + * @param "OrderID" (optional.String) - Order ID(s). + * @param "ClOrdID" (optional.String) - Client Order ID(s). See POST /order. + * @param "Text" (optional.String) - Optional cancellation annotation. e.g. 'Spread Exceeded'. + +@return []Order +*/ + +type OrderCancelOpts struct { + OrderID optional.String + ClOrdID optional.String + Text optional.String +} + +func (a *OrderApiService) OrderCancel(ctx context.Context, localVarOptionals *OrderCancelOpts) ([]Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.OrderID.IsSet() { + localVarFormParams.Add("orderID", parameterToString(localVarOptionals.OrderID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ClOrdID.IsSet() { + localVarFormParams.Add("clOrdID", parameterToString(localVarOptionals.ClOrdID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Text.IsSet() { + localVarFormParams.Add("text", parameterToString(localVarOptionals.Text.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Cancels all of your orders. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderCancelAllOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Optional symbol. If provided, only cancels orders for that symbol. + * @param "Filter" (optional.String) - Optional filter for cancellation. Use to only cancel some orders, e.g. `{\"side\": \"Buy\"}`. + * @param "Text" (optional.String) - Optional cancellation annotation. e.g. 'Spread Exceeded' + +@return []Order +*/ + +type OrderCancelAllOpts struct { + Symbol optional.String + Filter optional.String + Text optional.String +} + +func (a *OrderApiService) OrderCancelAll(ctx context.Context, localVarOptionals *OrderCancelAllOpts) ([]Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order/all" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarFormParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarFormParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Text.IsSet() { + localVarFormParams.Add("text", parameterToString(localVarOptionals.Text.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Automatically cancel all your orders after a specified timeout. +Useful as a dead-man's switch to ensure your orders are canceled in case of an outage. If called repeatedly, the existing offset will be canceled and a new one will be inserted in its place. Example usage: call this route at 15s intervals with an offset of 60000 (60s). If this route is not called within 60 seconds, all your orders will be automatically canceled. This is also available via [WebSocket](https://www.bitmex.com/app/wsAPI#Dead-Mans-Switch-Auto-Cancel). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param timeout Timeout in ms. Set to 0 to cancel this timer. + +@return interface{} +*/ +func (a *OrderApiService) OrderCancelAllAfter(ctx context.Context, timeout float64) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order/cancelAllAfter" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("timeout", parameterToString(timeout, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Close a position. [Deprecated, use POST /order with execInst: 'Close'] +If no `price` is specified, a market order will be submitted to close the whole of your position. This will also close all other open orders in this symbol. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Symbol of position to close. + * @param optional nil or *OrderClosePositionOpts - Optional Parameters: + * @param "Price" (optional.Float64) - Optional limit price. + +@return Order +*/ + +type OrderClosePositionOpts struct { + Price optional.Float64 +} + +func (a *OrderApiService) OrderClosePosition(ctx context.Context, symbol string, localVarOptionals *OrderClosePositionOpts) (Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order/closePosition" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + if localVarOptionals != nil && localVarOptionals.Price.IsSet() { + localVarFormParams.Add("price", parameterToString(localVarOptionals.Price.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Get your orders. +To get open orders only, send {\"open\": true} in the filter param. See <a href=\"http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_D_68.html\">the FIX Spec</a> for explanations of these fields. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderGetOrdersOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Order +*/ + +type OrderGetOrdersOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *OrderApiService) OrderGetOrders(ctx context.Context, localVarOptionals *OrderGetOrdersOpts) ([]Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Create a new order. +## Placing Orders This endpoint is used for placing orders. See individual fields below for more details on their use. #### Order Types All orders require a `symbol`. All other fields are optional except when otherwise specified. These are the valid `ordType`s: * **Limit**: The default order type. Specify an `orderQty` and `price`. * **Market**: A traditional Market order. A Market order will execute until filled or your bankruptcy price is reached, at which point it will cancel. * **MarketWithLeftOverAsLimit**: A market order that, after eating through the order book as far as permitted by available margin, will become a limit order. The difference between this type and `Market` only affects the behavior in thin books. Upon reaching the deepest possible price, if there is quantity left over, a `Market` order will cancel the remaining quantity. `MarketWithLeftOverAsLimit` will keep the remaining quantity in the books as a `Limit`. * **Stop**: A Stop Market order. Specify an `orderQty` and `stopPx`. When the `stopPx` is reached, the order will be entered into the book. * On sell orders, the order will trigger if the triggering price is lower than the `stopPx`. On buys, higher. * Note: Stop orders do not consume margin until triggered. Be sure that the required margin is available in your account so that it may trigger fully. * `Close` Stops don't require an `orderQty`. See Execution Instructions below. * **StopLimit**: Like a Stop Market, but enters a Limit order instead of a Market order. Specify an `orderQty`, `stopPx`, and `price`. * **MarketIfTouched**: Similar to a Stop, but triggers are done in the opposite direction. Useful for Take Profit orders. * **LimitIfTouched**: As above; use for Take Profit Limit orders. #### Execution Instructions The following `execInst`s are supported. If using multiple, separate with a comma (e.g. `LastPrice,Close`). * **ParticipateDoNotInitiate**: Also known as a Post-Only order. If this order would have executed on placement, it will cancel instead. * **AllOrNone**: Valid only for hidden orders (`displayQty: 0`). Use to only execute if the entire order would fill. * **MarkPrice, LastPrice, IndexPrice**: Used by stop and if-touched orders to determine the triggering price. Use only one. By default, `'MarkPrice'` is used. Also used for Pegged orders to define the value of `'LastPeg'`. * **ReduceOnly**: A `'ReduceOnly'` order can only reduce your position, not increase it. If you have a `'ReduceOnly'` limit order that rests in the order book while the position is reduced by other orders, then its order quantity will be amended down or canceled. If there are multiple `'ReduceOnly'` orders the least agresssive will be amended first. * **Close**: `'Close'` implies `'ReduceOnly'`. A `'Close'` order will cancel other active limit orders with the same side and symbol if the open quantity exceeds the current position. This is useful for stops: by canceling these orders, a `'Close'` Stop is ensured to have the margin required to execute, and can only execute up to the full size of your position. If `orderQty` is not specified, a `'Close'` order has an `orderQty` equal to your current position's size. * Note that a `Close` order without an `orderQty` requires a `side`, so that BitMEX knows if it should trigger above or below the `stopPx`. #### Linked Orders Linked Orders are an advanced capability. It is very powerful, but its use requires careful coding and testing. Please follow this document carefully and use the [Testnet Exchange](https://testnet.bitmex.com) while developing. BitMEX offers four advanced Linked Order types: * **OCO**: *One Cancels the Other*. A very flexible version of the standard Stop / Take Profit technique. Multiple orders may be linked together using a single `clOrdLinkID`. Send a `contingencyType` of `OneCancelsTheOther` on the orders. The first order that fully or partially executes (or activates for `Stop` orders) will cancel all other orders with the same `clOrdLinkID`. * **OTO**: *One Triggers the Other*. Send a `contingencyType` of `'OneTriggersTheOther'` on the primary order and then subsequent orders with the same `clOrdLinkID` will be not be triggered until the primary order fully executes. * **OUOA**: *One Updates the Other Absolute*. Send a `contingencyType` of `'OneUpdatesTheOtherAbsolute'` on the orders. Then as one order has a execution, other orders with the same `clOrdLinkID` will have their order quantity amended down by the execution quantity. * **OUOP**: *One Updates the Other Proportional*. Send a `contingencyType` of `'OneUpdatesTheOtherProportional'` on the orders. Then as one order has a execution, other orders with the same `clOrdLinkID` will have their order quantity reduced proportionally by the fill percentage. #### Trailing Stops You may use `pegPriceType` of `'TrailingStopPeg'` to create Trailing Stops. The pegged `stopPx` will move as the market moves away from the peg, and freeze as the market moves toward it. To use, combine with `pegOffsetValue` to set the `stopPx` of your order. The peg is set to the triggering price specified in the `execInst` (default `'MarkPrice'`). Use a negative offset for stop-sell and buy-if-touched orders. Requires `ordType`: `'Stop', 'StopLimit', 'MarketIfTouched', 'LimitIfTouched'`. #### Simple Quantities Send a `simpleOrderQty` instead of an `orderQty` to create an order denominated in the underlying currency. This is useful for opening up a position with 1 XBT of exposure without having to calculate how many contracts it is. #### Rate Limits See the [Bulk Order Documentation](#!/Order/Order_newBulk) if you need to place multiple orders at the same time. Bulk orders require fewer risk checks in the trading engine and thus are ratelimited at **1/10** the normal rate. You can also improve your reactivity to market movements while staying under your ratelimit by using the [Amend](#!/Order/Order_amend) and [Amend Bulk](#!/Order/Order_amendBulk) endpoints. This allows you to stay in the market and avoids the cancel/replace cycle. #### Tracking Your Orders If you want to keep track of order IDs yourself, set a unique `clOrdID` per order. This `clOrdID` will come back as a property on the order and any related executions (including on the WebSocket), and can be used to get or cancel the order. Max length is 36 characters. You can also change the `clOrdID` by amending an order, supplying an `origClOrdID`, and your desired new ID as the `clOrdID` param, like so: ``` # Amends an order's leavesQty, and updates its clOrdID to \"def-456\" PUT /api/v1/order {\"origClOrdID\": \"abc-123\", \"clOrdID\": \"def-456\", \"leavesQty\": 1000} ``` + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Instrument symbol. e.g. 'XBTUSD'. + * @param optional nil or *OrderNewOpts - Optional Parameters: + * @param "Side" (optional.String) - Order side. Valid options: Buy, Sell. Defaults to 'Buy' unless `orderQty` or `simpleOrderQty` is negative. + * @param "SimpleOrderQty" (optional.Float64) - Order quantity in units of the underlying instrument (i.e. Bitcoin). + * @param "OrderQty" (optional.Float32) - Order quantity in units of the instrument (i.e. contracts). + * @param "Price" (optional.Float64) - Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched' orders. + * @param "DisplayQty" (optional.Float32) - Optional quantity to display in the book. Use 0 for a fully hidden order. + * @param "StopPx" (optional.Float64) - Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. Use a price below the current price for stop-sell orders and buy-if-touched orders. Use `execInst` of 'MarkPrice' or 'LastPrice' to define the current price used for triggering. + * @param "ClOrdID" (optional.String) - Optional Client Order ID. This clOrdID will come back on the order and any related executions. + * @param "ClOrdLinkID" (optional.String) - Optional Client Order Link ID for contingent orders. + * @param "PegOffsetValue" (optional.Float64) - Optional trailing offset from the current price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative offset for stop-sell orders and buy-if-touched orders. Optional offset from the peg price for 'Pegged' orders. + * @param "PegPriceType" (optional.String) - Optional peg price type. Valid options: LastPeg, MidPricePeg, MarketPeg, PrimaryPeg, TrailingStopPeg. + * @param "OrdType" (optional.String) - Order type. Valid options: Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, Pegged. Defaults to 'Limit' when `price` is specified. Defaults to 'Stop' when `stopPx` is specified. Defaults to 'StopLimit' when `price` and `stopPx` are specified. + * @param "TimeInForce" (optional.String) - Time in force. Valid options: Day, GoodTillCancel, ImmediateOrCancel, FillOrKill. Defaults to 'GoodTillCancel' for 'Limit', 'StopLimit', 'LimitIfTouched', and 'MarketWithLeftOverAsLimit' orders. + * @param "ExecInst" (optional.String) - Optional execution instructions. Valid options: ParticipateDoNotInitiate, AllOrNone, MarkPrice, IndexPrice, LastPrice, Close, ReduceOnly, Fixed. 'AllOrNone' instruction requires `displayQty` to be 0. 'MarkPrice', 'IndexPrice' or 'LastPrice' instruction valid for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. + * @param "ContingencyType" (optional.String) - Optional contingency type for use with `clOrdLinkID`. Valid options: OneCancelsTheOther, OneTriggersTheOther, OneUpdatesTheOtherAbsolute, OneUpdatesTheOtherProportional. + * @param "Text" (optional.String) - Optional order annotation. e.g. 'Take profit'. + +@return Order +*/ + +type OrderNewOpts struct { + Side optional.String + SimpleOrderQty optional.Float64 + OrderQty optional.Float32 + Price optional.Float64 + DisplayQty optional.Float32 + StopPx optional.Float64 + ClOrdID optional.String + ClOrdLinkID optional.String + PegOffsetValue optional.Float64 + PegPriceType optional.String + OrdType optional.String + TimeInForce optional.String + ExecInst optional.String + ContingencyType optional.String + Text optional.String +} + +func (a *OrderApiService) OrderNew(ctx context.Context, symbol string, localVarOptionals *OrderNewOpts) (Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + if localVarOptionals != nil && localVarOptionals.Side.IsSet() { + localVarFormParams.Add("side", parameterToString(localVarOptionals.Side.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.SimpleOrderQty.IsSet() { + localVarFormParams.Add("simpleOrderQty", parameterToString(localVarOptionals.SimpleOrderQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OrderQty.IsSet() { + localVarFormParams.Add("orderQty", parameterToString(localVarOptionals.OrderQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Price.IsSet() { + localVarFormParams.Add("price", parameterToString(localVarOptionals.Price.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.DisplayQty.IsSet() { + localVarFormParams.Add("displayQty", parameterToString(localVarOptionals.DisplayQty.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StopPx.IsSet() { + localVarFormParams.Add("stopPx", parameterToString(localVarOptionals.StopPx.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ClOrdID.IsSet() { + localVarFormParams.Add("clOrdID", parameterToString(localVarOptionals.ClOrdID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ClOrdLinkID.IsSet() { + localVarFormParams.Add("clOrdLinkID", parameterToString(localVarOptionals.ClOrdLinkID.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PegOffsetValue.IsSet() { + localVarFormParams.Add("pegOffsetValue", parameterToString(localVarOptionals.PegOffsetValue.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PegPriceType.IsSet() { + localVarFormParams.Add("pegPriceType", parameterToString(localVarOptionals.PegPriceType.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OrdType.IsSet() { + localVarFormParams.Add("ordType", parameterToString(localVarOptionals.OrdType.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.TimeInForce.IsSet() { + localVarFormParams.Add("timeInForce", parameterToString(localVarOptionals.TimeInForce.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ExecInst.IsSet() { + localVarFormParams.Add("execInst", parameterToString(localVarOptionals.ExecInst.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.ContingencyType.IsSet() { + localVarFormParams.Add("contingencyType", parameterToString(localVarOptionals.ContingencyType.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Text.IsSet() { + localVarFormParams.Add("text", parameterToString(localVarOptionals.Text.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrderApiService Create multiple new orders for the same symbol. +This endpoint is used for placing bulk orders. Valid order types are Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, and Pegged. Each individual order object in the array should have the same properties as an individual POST /order call. This endpoint is much faster for getting many orders into the book at once. Because it reduces load on BitMEX systems, this endpoint is ratelimited at `ceil(0.1 * orders)`. Submitting 10 orders via a bulk order call will only count as 1 request, 15 as 2, 32 as 4, and so on. For now, only `application/json` is supported on this endpoint. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *OrderNewBulkOpts - Optional Parameters: + * @param "Orders" (optional.String) - An array of orders. + +@return []Order +*/ + +type OrderNewBulkOpts struct { + Orders optional.String +} + +func (a *OrderApiService) OrderNewBulk(ctx context.Context, localVarOptionals *OrderNewBulkOpts) ([]Order, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Order + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/order/bulk" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Orders.IsSet() { + localVarFormParams.Add("orders", parameterToString(localVarOptionals.Orders.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_order_book.go b/api_order_book.go new file mode 100644 index 0000000..fa63998 --- /dev/null +++ b/api_order_book.go @@ -0,0 +1,158 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type OrderBookApiService service + +/* +OrderBookApiService Get current orderbook in vertical format. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Instrument symbol. Send a series (e.g. XBT) to get data for the nearest contract in that series. + * @param optional nil or *OrderBookGetL2Opts - Optional Parameters: + * @param "Depth" (optional.Float32) - Orderbook depth per side. Send 0 for full depth. + +@return []OrderBookL2 +*/ + +type OrderBookGetL2Opts struct { + Depth optional.Float32 +} + +func (a *OrderBookApiService) OrderBookGetL2(ctx context.Context, symbol string, localVarOptionals *OrderBookGetL2Opts) ([]OrderBookL2, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []OrderBookL2 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/orderBook/L2" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + localVarQueryParams.Add("symbol", parameterToString(symbol, "")) + if localVarOptionals != nil && localVarOptionals.Depth.IsSet() { + localVarQueryParams.Add("depth", parameterToString(localVarOptionals.Depth.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []OrderBookL2 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_position.go b/api_position.go new file mode 100644 index 0000000..28ae7e8 --- /dev/null +++ b/api_position.go @@ -0,0 +1,862 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type PositionApiService service + +/* +PositionApiService Get your positions. +See <a href=\"http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_AP_6580.html\">the FIX Spec</a> for explanations of these fields. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *PositionGetOpts - Optional Parameters: + * @param "Filter" (optional.String) - Table filter. For example, send {\"symbol\": \"XBTUSD\"}. + * @param "Columns" (optional.String) - Which columns to fetch. For example, send [\"columnName\"]. + * @param "Count" (optional.Float32) - Number of rows to fetch. + +@return []Position +*/ + +type PositionGetOpts struct { + Filter optional.String + Columns optional.String + Count optional.Float32 +} + +func (a *PositionApiService) PositionGet(ctx context.Context, localVarOptionals *PositionGetOpts) ([]Position, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Position + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/position" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Position + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +PositionApiService Enable isolated margin or cross margin per-position. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Position symbol to isolate. + * @param optional nil or *PositionIsolateMarginOpts - Optional Parameters: + * @param "Enabled" (optional.Bool) - True for isolated margin, false for cross margin. + +@return Position +*/ + +type PositionIsolateMarginOpts struct { + Enabled optional.Bool +} + +func (a *PositionApiService) PositionIsolateMargin(ctx context.Context, symbol string, localVarOptionals *PositionIsolateMarginOpts) (Position, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Position + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/position/isolate" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + if localVarOptionals != nil && localVarOptionals.Enabled.IsSet() { + localVarFormParams.Add("enabled", parameterToString(localVarOptionals.Enabled.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Position + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +PositionApiService Transfer equity in or out of a position. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Symbol of position to isolate. + * @param amount Amount to transfer, in Satoshis. May be negative. + +@return Position +*/ +func (a *PositionApiService) PositionTransferIsolatedMargin(ctx context.Context, symbol string, amount float32) (Position, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Position + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/position/transferMargin" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + localVarFormParams.Add("amount", parameterToString(amount, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Position + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +PositionApiService Choose leverage for a position. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Symbol of position to adjust. + * @param leverage Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin. + +@return Position +*/ +func (a *PositionApiService) PositionUpdateLeverage(ctx context.Context, symbol string, leverage float64) (Position, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Position + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/position/leverage" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + localVarFormParams.Add("leverage", parameterToString(leverage, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Position + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +PositionApiService Update your risk limit. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param symbol Symbol of position to update risk limit on. + * @param riskLimit New Risk Limit, in Satoshis. + +@return Position +*/ +func (a *PositionApiService) PositionUpdateRiskLimit(ctx context.Context, symbol string, riskLimit float32) (Position, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Position + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/position/riskLimit" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("symbol", parameterToString(symbol, "")) + localVarFormParams.Add("riskLimit", parameterToString(riskLimit, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Position + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_quote.go b/api_quote.go new file mode 100644 index 0000000..8f07deb --- /dev/null +++ b/api_quote.go @@ -0,0 +1,365 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type QuoteApiService service + +/* +QuoteApiService Get Quotes. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *QuoteGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Quote +*/ + +type QuoteGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *QuoteApiService) QuoteGet(ctx context.Context, localVarOptionals *QuoteGetOpts) ([]Quote, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Quote + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/quote" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Quote + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +QuoteApiService Get previous quotes in time buckets. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *QuoteGetBucketedOpts - Optional Parameters: + * @param "BinSize" (optional.String) - Time interval to bucket by. Available options: [1m,5m,1h,1d]. + * @param "Partial" (optional.Bool) - If true, will send in-progress (incomplete) bins for the current time period. + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Quote +*/ + +type QuoteGetBucketedOpts struct { + BinSize optional.String + Partial optional.Bool + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *QuoteApiService) QuoteGetBucketed(ctx context.Context, localVarOptionals *QuoteGetBucketedOpts) ([]Quote, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Quote + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/quote/bucketed" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.BinSize.IsSet() { + localVarQueryParams.Add("binSize", parameterToString(localVarOptionals.BinSize.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Partial.IsSet() { + localVarQueryParams.Add("partial", parameterToString(localVarOptionals.Partial.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Quote + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_schema.go b/api_schema.go new file mode 100644 index 0000000..b94a408 --- /dev/null +++ b/api_schema.go @@ -0,0 +1,275 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type SchemaApiService service + +/* +SchemaApiService Get model schemata for data objects returned by this API. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *SchemaGetOpts - Optional Parameters: + * @param "Model" (optional.String) - Optional model filter. If omitted, will return all models. + +@return interface{} +*/ + +type SchemaGetOpts struct { + Model optional.String +} + +func (a *SchemaApiService) SchemaGet(ctx context.Context, localVarOptionals *SchemaGetOpts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/schema" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Model.IsSet() { + localVarQueryParams.Add("model", parameterToString(localVarOptionals.Model.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +SchemaApiService Returns help text & subject list for websocket usage. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return interface{} +*/ +func (a *SchemaApiService) SchemaWebsocketHelp(ctx context.Context) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/schema/websocketHelp" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_settlement.go b/api_settlement.go new file mode 100644 index 0000000..acc7682 --- /dev/null +++ b/api_settlement.go @@ -0,0 +1,191 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type SettlementApiService service + +/* +SettlementApiService Get settlement history. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *SettlementGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Settlement +*/ + +type SettlementGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *SettlementApiService) SettlementGet(ctx context.Context, localVarOptionals *SettlementGetOpts) ([]Settlement, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Settlement + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/settlement" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Settlement + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_stats.go b/api_stats.go new file mode 100644 index 0000000..a659c4a --- /dev/null +++ b/api_stats.go @@ -0,0 +1,383 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +// Linger please +var ( + _ context.Context +) + +type StatsApiService service + +/* +StatsApiService Get exchange-wide and per-series turnover and volume statistics. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []Stats +*/ +func (a *StatsApiService) StatsGet(ctx context.Context) ([]Stats, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Stats + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/stats" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Stats + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +StatsApiService Get historical exchange-wide and per-series turnover and volume statistics. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []StatsHistory +*/ +func (a *StatsApiService) StatsHistory(ctx context.Context) ([]StatsHistory, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []StatsHistory + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/stats/history" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []StatsHistory + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +StatsApiService Get a summary of exchange statistics in USD. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []StatsUsd +*/ +func (a *StatsApiService) StatsHistoryUSD(ctx context.Context) ([]StatsUsd, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []StatsUsd + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/stats/historyUSD" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []StatsUsd + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_trade.go b/api_trade.go new file mode 100644 index 0000000..9667dce --- /dev/null +++ b/api_trade.go @@ -0,0 +1,366 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type TradeApiService service + +/* +TradeApiService Get Trades. +Please note that indices (symbols starting with `.`) post trades at intervals to the trade feed. These have a `size` of 0 and are used only to indicate a changing price. See [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_AE_6569.html) for explanations of these fields. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *TradeGetOpts - Optional Parameters: + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []Trade +*/ + +type TradeGetOpts struct { + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *TradeApiService) TradeGet(ctx context.Context, localVarOptionals *TradeGetOpts) ([]Trade, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Trade + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/trade" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Trade + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +TradeApiService Get previous trades in time buckets. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *TradeGetBucketedOpts - Optional Parameters: + * @param "BinSize" (optional.String) - Time interval to bucket by. Available options: [1m,5m,1h,1d]. + * @param "Partial" (optional.Bool) - If true, will send in-progress (incomplete) bins for the current time period. + * @param "Symbol" (optional.String) - Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. + * @param "Filter" (optional.String) - Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. + * @param "Columns" (optional.String) - Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. + * @param "Count" (optional.Float32) - Number of results to fetch. + * @param "Start" (optional.Float32) - Starting point for results. + * @param "Reverse" (optional.Bool) - If true, will sort results newest first. + * @param "StartTime" (optional.Time) - Starting date filter for results. + * @param "EndTime" (optional.Time) - Ending date filter for results. + +@return []TradeBin +*/ + +type TradeGetBucketedOpts struct { + BinSize optional.String + Partial optional.Bool + Symbol optional.String + Filter optional.String + Columns optional.String + Count optional.Float32 + Start optional.Float32 + Reverse optional.Bool + StartTime optional.Time + EndTime optional.Time +} + +func (a *TradeApiService) TradeGetBucketed(ctx context.Context, localVarOptionals *TradeGetBucketedOpts) ([]TradeBin, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []TradeBin + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/trade/bucketed" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.BinSize.IsSet() { + localVarQueryParams.Add("binSize", parameterToString(localVarOptionals.BinSize.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Partial.IsSet() { + localVarQueryParams.Add("partial", parameterToString(localVarOptionals.Partial.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Symbol.IsSet() { + localVarQueryParams.Add("symbol", parameterToString(localVarOptionals.Symbol.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Filter.IsSet() { + localVarQueryParams.Add("filter", parameterToString(localVarOptionals.Filter.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Columns.IsSet() { + localVarQueryParams.Add("columns", parameterToString(localVarOptionals.Columns.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Count.IsSet() { + localVarQueryParams.Add("count", parameterToString(localVarOptionals.Count.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Start.IsSet() { + localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.StartTime.IsSet() { + localVarQueryParams.Add("startTime", parameterToString(localVarOptionals.StartTime.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.EndTime.IsSet() { + localVarQueryParams.Add("endTime", parameterToString(localVarOptionals.EndTime.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []TradeBin + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 400 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 401 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + if localVarHttpResponse.StatusCode == 404 { + var v ModelError + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/api_user.go b/api_user.go new file mode 100644 index 0000000..4a444b3 --- /dev/null +++ b/api_user.go @@ -0,0 +1,2592 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type UserApiService service + +/* +UserApiService Cancel a withdrawal. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param token + +@return Transaction +*/ +func (a *UserApiService) UserCancelWithdrawal(ctx context.Context, token string) (Transaction, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Transaction + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/cancelWithdrawal" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("token", parameterToString(token, "")) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Transaction + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Check if a referral code is valid. +If the code is valid, responds with the referral code's discount (e.g. `0.1` for 10%). Otherwise, will return a 404. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserCheckReferralCodeOpts - Optional Parameters: + * @param "ReferralCode" (optional.String) - + +@return float64 +*/ + +type UserCheckReferralCodeOpts struct { + ReferralCode optional.String +} + +func (a *UserApiService) UserCheckReferralCode(ctx context.Context, localVarOptionals *UserCheckReferralCodeOpts) (float64, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue float64 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/checkReferralCode" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.ReferralCode.IsSet() { + localVarQueryParams.Add("referralCode", parameterToString(localVarOptionals.ReferralCode.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v float64 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Confirm your email address with a token. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param token + +@return AccessToken +*/ +func (a *UserApiService) UserConfirm(ctx context.Context, token string) (AccessToken, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue AccessToken + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/confirmEmail" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("token", parameterToString(token, "")) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v AccessToken + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Confirm two-factor auth for this account. If using a Yubikey, simply send a token to this endpoint. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param token Token from your selected TFA type. + * @param optional nil or *UserConfirmEnableTFAOpts - Optional Parameters: + * @param "Type_" (optional.String) - Two-factor auth type. Supported types: 'GA' (Google Authenticator), 'Yubikey' + +@return bool +*/ + +type UserConfirmEnableTFAOpts struct { + Type_ optional.String +} + +func (a *UserApiService) UserConfirmEnableTFA(ctx context.Context, token string, localVarOptionals *UserConfirmEnableTFAOpts) (bool, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue bool + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/confirmEnableTFA" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Type_.IsSet() { + localVarFormParams.Add("type", parameterToString(localVarOptionals.Type_.Value(), "")) + } + localVarFormParams.Add("token", parameterToString(token, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v bool + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Confirm a withdrawal. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param token + +@return Transaction +*/ +func (a *UserApiService) UserConfirmWithdrawal(ctx context.Context, token string) (Transaction, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Transaction + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/confirmWithdrawal" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("token", parameterToString(token, "")) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Transaction + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Disable two-factor auth for this account. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param token Token from your selected TFA type. + * @param optional nil or *UserDisableTFAOpts - Optional Parameters: + * @param "Type_" (optional.String) - Two-factor auth type. Supported types: 'GA' (Google Authenticator) + +@return bool +*/ + +type UserDisableTFAOpts struct { + Type_ optional.String +} + +func (a *UserApiService) UserDisableTFA(ctx context.Context, token string, localVarOptionals *UserDisableTFAOpts) (bool, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue bool + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/disableTFA" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Type_.IsSet() { + localVarFormParams.Add("type", parameterToString(localVarOptionals.Type_.Value(), "")) + } + localVarFormParams.Add("token", parameterToString(token, "")) + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v bool + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get your user model. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return User +*/ +func (a *UserApiService) UserGet(ctx context.Context) (User, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue User + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v User + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get your current affiliate/referral status. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return Affiliate +*/ +func (a *UserApiService) UserGetAffiliateStatus(ctx context.Context) (Affiliate, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Affiliate + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/affiliateStatus" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Affiliate + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get your account's commission status. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return []UserCommission +*/ +func (a *UserApiService) UserGetCommission(ctx context.Context) ([]UserCommission, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []UserCommission + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/commission" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []UserCommission + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get a deposit address. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserGetDepositAddressOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return string +*/ + +type UserGetDepositAddressOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserGetDepositAddress(ctx context.Context, localVarOptionals *UserGetDepositAddressOpts) (string, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue string + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/depositAddress" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get your account's margin status. Send a currency of \"all\" to receive an array of all supported currencies. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserGetMarginOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return Margin +*/ + +type UserGetMarginOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserGetMargin(ctx context.Context, localVarOptionals *UserGetMarginOpts) (Margin, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Margin + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/margin" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Margin + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get your current wallet information. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserGetWalletOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return Wallet +*/ + +type UserGetWalletOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserGetWallet(ctx context.Context, localVarOptionals *UserGetWalletOpts) (Wallet, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Wallet + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/wallet" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Wallet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get a history of all of your wallet transactions (deposits, withdrawals, PNL). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserGetWalletHistoryOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return []Transaction +*/ + +type UserGetWalletHistoryOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserGetWalletHistory(ctx context.Context, localVarOptionals *UserGetWalletHistoryOpts) ([]Transaction, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Transaction + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/walletHistory" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Transaction + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get a summary of all of your wallet transactions (deposits, withdrawals, PNL). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserGetWalletSummaryOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return []Transaction +*/ + +type UserGetWalletSummaryOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserGetWalletSummary(ctx context.Context, localVarOptionals *UserGetWalletSummaryOpts) ([]Transaction, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Transaction + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/walletSummary" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Transaction + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Log out of BitMEX. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + + +*/ +func (a *UserApiService) UserLogout(ctx context.Context) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/logout" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil +} + +/* +UserApiService Log all systems out of BitMEX. This will revoke all of your account's access tokens, logging you out on all devices. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@return float64 +*/ +func (a *UserApiService) UserLogoutAll(ctx context.Context) (float64, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue float64 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/logoutAll" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v float64 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get the minimum withdrawal fee for a currency. +This is changed based on network conditions to ensure timely withdrawals. During network congestion, this may be high. The fee is returned in the same currency. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserMinWithdrawalFeeOpts - Optional Parameters: + * @param "Currency" (optional.String) - + +@return interface{} +*/ + +type UserMinWithdrawalFeeOpts struct { + Currency optional.String +} + +func (a *UserApiService) UserMinWithdrawalFee(ctx context.Context, localVarOptionals *UserMinWithdrawalFeeOpts) (interface{}, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue interface{} + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/minWithdrawalFee" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Get secret key for setting up two-factor auth. +Use /confirmEnableTFA directly for Yubikeys. This fails if TFA is already enabled. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserRequestEnableTFAOpts - Optional Parameters: + * @param "Type_" (optional.String) - Two-factor auth type. Supported types: 'GA' (Google Authenticator) + +@return bool +*/ + +type UserRequestEnableTFAOpts struct { + Type_ optional.String +} + +func (a *UserApiService) UserRequestEnableTFA(ctx context.Context, localVarOptionals *UserRequestEnableTFAOpts) (bool, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue bool + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/requestEnableTFA" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Type_.IsSet() { + localVarFormParams.Add("type", parameterToString(localVarOptionals.Type_.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v bool + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Request a withdrawal to an external wallet. +This will send a confirmation email to the email address on record, unless requested via an API Key with the `withdraw` permission. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param currency Currency you're withdrawing. Options: `XBt` + * @param amount Amount of withdrawal currency. + * @param address Destination Address. + * @param optional nil or *UserRequestWithdrawalOpts - Optional Parameters: + * @param "OtpToken" (optional.String) - 2FA token. Required if 2FA is enabled on your account. + * @param "Fee" (optional.Float64) - Network fee for Bitcoin withdrawals. If not specified, a default value will be calculated based on Bitcoin network conditions. You will have a chance to confirm this via email. + +@return Transaction +*/ + +type UserRequestWithdrawalOpts struct { + OtpToken optional.String + Fee optional.Float64 +} + +func (a *UserApiService) UserRequestWithdrawal(ctx context.Context, currency string, amount float32, address string, localVarOptionals *UserRequestWithdrawalOpts) (Transaction, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Transaction + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/requestWithdrawal" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.OtpToken.IsSet() { + localVarFormParams.Add("otpToken", parameterToString(localVarOptionals.OtpToken.Value(), "")) + } + localVarFormParams.Add("currency", parameterToString(currency, "")) + localVarFormParams.Add("amount", parameterToString(amount, "")) + localVarFormParams.Add("address", parameterToString(address, "")) + if localVarOptionals != nil && localVarOptionals.Fee.IsSet() { + localVarFormParams.Add("fee", parameterToString(localVarOptionals.Fee.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Transaction + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Save user preferences. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param prefs + * @param optional nil or *UserSavePreferencesOpts - Optional Parameters: + * @param "Overwrite" (optional.Bool) - If true, will overwrite all existing preferences. + +@return User +*/ + +type UserSavePreferencesOpts struct { + Overwrite optional.Bool +} + +func (a *UserApiService) UserSavePreferences(ctx context.Context, prefs string, localVarOptionals *UserSavePreferencesOpts) (User, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue User + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user/preferences" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + localVarFormParams.Add("prefs", parameterToString(prefs, "")) + if localVarOptionals != nil && localVarOptionals.Overwrite.IsSet() { + localVarFormParams.Add("overwrite", parameterToString(localVarOptionals.Overwrite.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v User + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +UserApiService Update your password, name, and other attributes. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserUpdateOpts - Optional Parameters: + * @param "Firstname" (optional.String) - + * @param "Lastname" (optional.String) - + * @param "OldPassword" (optional.String) - + * @param "NewPassword" (optional.String) - + * @param "NewPasswordConfirm" (optional.String) - + * @param "Username" (optional.String) - Username can only be set once. To reset, email support. + * @param "Country" (optional.String) - Country of residence. + * @param "PgpPubKey" (optional.String) - PGP Public Key. If specified, automated emails will be sentwith this key. + +@return User +*/ + +type UserUpdateOpts struct { + Firstname optional.String + Lastname optional.String + OldPassword optional.String + NewPassword optional.String + NewPasswordConfirm optional.String + Username optional.String + Country optional.String + PgpPubKey optional.String +} + +func (a *UserApiService) UserUpdate(ctx context.Context, localVarOptionals *UserUpdateOpts) (User, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue User + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/user" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.Firstname.IsSet() { + localVarFormParams.Add("firstname", parameterToString(localVarOptionals.Firstname.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Lastname.IsSet() { + localVarFormParams.Add("lastname", parameterToString(localVarOptionals.Lastname.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.OldPassword.IsSet() { + localVarFormParams.Add("oldPassword", parameterToString(localVarOptionals.OldPassword.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NewPassword.IsSet() { + localVarFormParams.Add("newPassword", parameterToString(localVarOptionals.NewPassword.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.NewPasswordConfirm.IsSet() { + localVarFormParams.Add("newPasswordConfirm", parameterToString(localVarOptionals.NewPasswordConfirm.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Username.IsSet() { + localVarFormParams.Add("username", parameterToString(localVarOptionals.Username.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Country.IsSet() { + localVarFormParams.Add("country", parameterToString(localVarOptionals.Country.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.PgpPubKey.IsSet() { + localVarFormParams.Add("pgpPubKey", parameterToString(localVarOptionals.PgpPubKey.Value(), "")) + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-key"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-nonce"] = key + + } + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["api-signature"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v User + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/client.go b/client.go new file mode 100644 index 0000000..209a6a4 --- /dev/null +++ b/client.go @@ -0,0 +1,519 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") +) + +// APIClient manages communication with the BitMEX API API v1.2.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + APIKeyApi *APIKeyApiService + + AnnouncementApi *AnnouncementApiService + + ChatApi *ChatApiService + + ExecutionApi *ExecutionApiService + + FundingApi *FundingApiService + + InstrumentApi *InstrumentApiService + + InsuranceApi *InsuranceApiService + + LeaderboardApi *LeaderboardApiService + + LiquidationApi *LiquidationApiService + + NotificationApi *NotificationApiService + + OrderApi *OrderApiService + + OrderBookApi *OrderBookApiService + + PositionApi *PositionApiService + + QuoteApi *QuoteApiService + + SchemaApi *SchemaApiService + + SettlementApi *SettlementApiService + + StatsApi *StatsApiService + + TradeApi *TradeApiService + + UserApi *UserApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.APIKeyApi = (*APIKeyApiService)(&c.common) + c.AnnouncementApi = (*AnnouncementApiService)(&c.common) + c.ChatApi = (*ChatApiService)(&c.common) + c.ExecutionApi = (*ExecutionApiService)(&c.common) + c.FundingApi = (*FundingApiService)(&c.common) + c.InstrumentApi = (*InstrumentApiService)(&c.common) + c.InsuranceApi = (*InsuranceApiService)(&c.common) + c.LeaderboardApi = (*LeaderboardApiService)(&c.common) + c.LiquidationApi = (*LiquidationApiService)(&c.common) + c.NotificationApi = (*NotificationApiService)(&c.common) + c.OrderApi = (*OrderApiService)(&c.common) + c.OrderBookApi = (*OrderBookApiService)(&c.common) + c.PositionApi = (*PositionApiService)(&c.common) + c.QuoteApi = (*QuoteApiService)(&c.common) + c.SchemaApi = (*SchemaApiService)(&c.common) + c.SettlementApi = (*SettlementApiService)(&c.common) + c.StatsApi = (*StatsApiService)(&c.common) + c.TradeApi = (*TradeApiService)(&c.common) + c.UserApi = (*UserApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insenstive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.ToLower(a) == strings.ToLower(needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + + switch collectionFormat { + case "pipes": + delimiter = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," + } + + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } + + return fmt.Sprintf("%v", obj) +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} + +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath(path string) { + c.cfg.BasePath = path +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + fileName string, + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + } + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = query.Encode() + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers + } + + // Override request host, if applicable + if c.cfg.Host != "" { + localVarRequest.Host = c.cfg.Host + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/configuration.go b/configuration.go new file mode 100644 index 0000000..20822a6 --- /dev/null +++ b/configuration.go @@ -0,0 +1,73 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "net/http" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextBasicAuth takes BasicAuth as authentication for the request. + ContextBasicAuth = contextKey("basic") + + // ContextAccessToken takes a string oauth2 access token as authentication for the request. + ContextAccessToken = contextKey("accesstoken") + + // ContextAPIKey takes an APIKey as authentication for the request + ContextAPIKey = contextKey("apikey") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +type Configuration struct { + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client +} + +func NewConfiguration() *Configuration { + cfg := &Configuration{ + BasePath: "https://localhost/api/v1", + DefaultHeader: make(map[string]string), + UserAgent: "Swagger-Codegen/1.0.0/go", + } + return cfg +} + +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} diff --git a/docs/APIKeyApi.md b/docs/APIKeyApi.md new file mode 100644 index 0000000..6b89101 --- /dev/null +++ b/docs/APIKeyApi.md @@ -0,0 +1,163 @@ +# \APIKeyApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**APIKeyDisable**](APIKeyApi.md#APIKeyDisable) | **Post** /apiKey/disable | Disable an API Key. +[**APIKeyEnable**](APIKeyApi.md#APIKeyEnable) | **Post** /apiKey/enable | Enable an API Key. +[**APIKeyGet**](APIKeyApi.md#APIKeyGet) | **Get** /apiKey | Get your API Keys. +[**APIKeyNew**](APIKeyApi.md#APIKeyNew) | **Post** /apiKey | Create a new API Key. +[**APIKeyRemove**](APIKeyApi.md#APIKeyRemove) | **Delete** /apiKey | Remove an API Key. + + +# **APIKeyDisable** +> ApiKey APIKeyDisable(ctx, apiKeyID) +Disable an API Key. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **apiKeyID** | **string**| API Key ID (public component). | + +### Return type + +[**ApiKey**](APIKey.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **APIKeyEnable** +> ApiKey APIKeyEnable(ctx, apiKeyID) +Enable an API Key. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **apiKeyID** | **string**| API Key ID (public component). | + +### Return type + +[**ApiKey**](APIKey.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **APIKeyGet** +> []ApiKey APIKeyGet(ctx, optional) +Get your API Keys. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***APIKeyGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a APIKeyGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + +### Return type + +[**[]ApiKey**](APIKey.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **APIKeyNew** +> ApiKey APIKeyNew(ctx, optional) +Create a new API Key. + +API Keys can only be created via the frontend. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***APIKeyNewOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a APIKeyNewOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **optional.String**| Key name. This name is for reference only. | + **cidr** | **optional.String**| CIDR block to restrict this key to. To restrict to a single address, append \"/32\", e.g. 207.39.29.22/32. Leave blank or set to 0.0.0.0/0 to allow all IPs. Only one block may be set. <a href=\"http://software77.net/cidr-101.html\">More on CIDR blocks</a> | + **permissions** | **optional.String**| Key Permissions. All keys can read margin and position data. Additional permissions must be added. Available: [\"order\", \"orderCancel\", \"withdraw\"]. | + **enabled** | **optional.Bool**| Set to true to enable this key on creation. Otherwise, it must be explicitly enabled via /apiKey/enable. | [default to false] + **token** | **optional.String**| OTP Token (YubiKey, Google Authenticator) | + +### Return type + +[**ApiKey**](APIKey.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **APIKeyRemove** +> InlineResponse200 APIKeyRemove(ctx, apiKeyID) +Remove an API Key. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **apiKeyID** | **string**| API Key ID (public component). | + +### Return type + +[**InlineResponse200**](inline_response_200.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/AccessToken.md b/docs/AccessToken.md new file mode 100644 index 0000000..7e1ce63 --- /dev/null +++ b/docs/AccessToken.md @@ -0,0 +1,13 @@ +# AccessToken + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [default to null] +**Ttl** | **float64** | time to live in seconds (2 weeks by default) | [optional] [default to 1209600.0] +**Created** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**UserId** | **float64** | | [optional] [default to null] + +[[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/docs/Affiliate.md b/docs/Affiliate.md new file mode 100644 index 0000000..705151a --- /dev/null +++ b/docs/Affiliate.md @@ -0,0 +1,24 @@ +# Affiliate + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Account** | **float32** | | [default to null] +**Currency** | **string** | | [default to null] +**PrevPayout** | **float32** | | [optional] [default to null] +**PrevTurnover** | **float32** | | [optional] [default to null] +**PrevComm** | **float32** | | [optional] [default to null] +**PrevTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**ExecTurnover** | **float32** | | [optional] [default to null] +**ExecComm** | **float32** | | [optional] [default to null] +**TotalReferrals** | **float32** | | [optional] [default to null] +**TotalTurnover** | **float32** | | [optional] [default to null] +**TotalComm** | **float32** | | [optional] [default to null] +**PayoutPcnt** | **float64** | | [optional] [default to null] +**PendingPayout** | **float32** | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**ReferrerAccount** | **float64** | | [optional] [default to null] + +[[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/docs/Announcement.md b/docs/Announcement.md new file mode 100644 index 0000000..b16d514 --- /dev/null +++ b/docs/Announcement.md @@ -0,0 +1,14 @@ +# Announcement + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **float32** | | [default to null] +**Link** | **string** | | [optional] [default to null] +**Title** | **string** | | [optional] [default to null] +**Content** | **string** | | [optional] [default to null] +**Date** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/AnnouncementApi.md b/docs/AnnouncementApi.md new file mode 100644 index 0000000..4a31d51 --- /dev/null +++ b/docs/AnnouncementApi.md @@ -0,0 +1,65 @@ +# \AnnouncementApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**AnnouncementGet**](AnnouncementApi.md#AnnouncementGet) | **Get** /announcement | Get site announcements. +[**AnnouncementGetUrgent**](AnnouncementApi.md#AnnouncementGetUrgent) | **Get** /announcement/urgent | Get urgent (banner) announcements. + + +# **AnnouncementGet** +> []Announcement AnnouncementGet(ctx, optional) +Get site announcements. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***AnnouncementGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a AnnouncementGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. | + +### Return type + +[**[]Announcement**](Announcement.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **AnnouncementGetUrgent** +> []Announcement AnnouncementGetUrgent(ctx, ) +Get urgent (banner) announcements. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Announcement**](Announcement.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/ApiKey.md b/docs/ApiKey.md new file mode 100644 index 0000000..25d5797 --- /dev/null +++ b/docs/ApiKey.md @@ -0,0 +1,18 @@ +# ApiKey + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [default to null] +**Secret** | **string** | | [default to null] +**Name** | **string** | | [default to null] +**Nonce** | **float32** | | [default to null] +**Cidr** | **string** | | [optional] [default to null] +**Permissions** | [**[]XAny**](x-any.md) | | [optional] [default to null] +**Enabled** | **bool** | | [optional] [default to null] +**UserId** | **float32** | | [default to null] +**Created** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/Chat.md b/docs/Chat.md new file mode 100644 index 0000000..40399e8 --- /dev/null +++ b/docs/Chat.md @@ -0,0 +1,16 @@ +# Chat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **float32** | | [optional] [default to null] +**Date** | [**time.Time**](time.Time.md) | | [default to null] +**User** | **string** | | [default to null] +**Message** | **string** | | [default to null] +**Html** | **string** | | [default to null] +**FromBot** | **bool** | | [optional] [default to null] +**ChannelID** | **float64** | | [optional] [default to null] + +[[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/docs/ChatApi.md b/docs/ChatApi.md new file mode 100644 index 0000000..c891d69 --- /dev/null +++ b/docs/ChatApi.md @@ -0,0 +1,129 @@ +# \ChatApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**ChatGet**](ChatApi.md#ChatGet) | **Get** /chat | Get chat messages. +[**ChatGetChannels**](ChatApi.md#ChatGetChannels) | **Get** /chat/channels | Get available channels. +[**ChatGetConnected**](ChatApi.md#ChatGetConnected) | **Get** /chat/connected | Get connected users. +[**ChatNew**](ChatApi.md#ChatNew) | **Post** /chat | Send a chat message. + + +# **ChatGet** +> []Chat ChatGet(ctx, optional) +Get chat messages. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***ChatGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a ChatGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting ID for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to true] + **channelID** | **optional.Float64**| Channel id. GET /chat/channels for ids. Leave blank for all. | + +### Return type + +[**[]Chat**](Chat.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **ChatGetChannels** +> []ChatChannel ChatGetChannels(ctx, ) +Get available channels. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]ChatChannel**](ChatChannel.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **ChatGetConnected** +> ConnectedUsers ChatGetConnected(ctx, ) +Get connected users. + +Returns an array with browser users in the first position and API users (bots) in the second position. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**ConnectedUsers**](ConnectedUsers.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **ChatNew** +> Chat ChatNew(ctx, message, optional) +Send a chat message. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **message** | **string**| | + **optional** | ***ChatNewOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a ChatNewOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **channelID** | **optional.Float64**| Channel to post to. Default 1 (English). | [default to 1] + +### Return type + +[**Chat**](Chat.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/ChatChannel.md b/docs/ChatChannel.md new file mode 100644 index 0000000..e7e4151 --- /dev/null +++ b/docs/ChatChannel.md @@ -0,0 +1,11 @@ +# ChatChannel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **float32** | | [optional] [default to null] +**Name** | **string** | | [default to null] + +[[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/docs/ConnectedUsers.md b/docs/ConnectedUsers.md new file mode 100644 index 0000000..c99e3fb --- /dev/null +++ b/docs/ConnectedUsers.md @@ -0,0 +1,11 @@ +# ConnectedUsers + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Users** | **float32** | | [optional] [default to null] +**Bots** | **float32** | | [optional] [default to null] + +[[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/docs/ErrorError.md b/docs/ErrorError.md new file mode 100644 index 0000000..3b478db --- /dev/null +++ b/docs/ErrorError.md @@ -0,0 +1,11 @@ +# ErrorError + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Message** | **string** | | [optional] [default to null] +**Name** | **string** | | [optional] [default to null] + +[[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/docs/Execution.md b/docs/Execution.md new file mode 100644 index 0000000..9b90d81 --- /dev/null +++ b/docs/Execution.md @@ -0,0 +1,56 @@ +# Execution + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ExecID** | **string** | | [default to null] +**OrderID** | **string** | | [optional] [default to null] +**ClOrdID** | **string** | | [optional] [default to null] +**ClOrdLinkID** | **string** | | [optional] [default to null] +**Account** | **float32** | | [optional] [default to null] +**Symbol** | **string** | | [optional] [default to null] +**Side** | **string** | | [optional] [default to null] +**LastQty** | **float32** | | [optional] [default to null] +**LastPx** | **float64** | | [optional] [default to null] +**UnderlyingLastPx** | **float64** | | [optional] [default to null] +**LastMkt** | **string** | | [optional] [default to null] +**LastLiquidityInd** | **string** | | [optional] [default to null] +**SimpleOrderQty** | **float64** | | [optional] [default to null] +**OrderQty** | **float32** | | [optional] [default to null] +**Price** | **float64** | | [optional] [default to null] +**DisplayQty** | **float32** | | [optional] [default to null] +**StopPx** | **float64** | | [optional] [default to null] +**PegOffsetValue** | **float64** | | [optional] [default to null] +**PegPriceType** | **string** | | [optional] [default to null] +**Currency** | **string** | | [optional] [default to null] +**SettlCurrency** | **string** | | [optional] [default to null] +**ExecType** | **string** | | [optional] [default to null] +**OrdType** | **string** | | [optional] [default to null] +**TimeInForce** | **string** | | [optional] [default to null] +**ExecInst** | **string** | | [optional] [default to null] +**ContingencyType** | **string** | | [optional] [default to null] +**ExDestination** | **string** | | [optional] [default to null] +**OrdStatus** | **string** | | [optional] [default to null] +**Triggered** | **string** | | [optional] [default to null] +**WorkingIndicator** | **bool** | | [optional] [default to null] +**OrdRejReason** | **string** | | [optional] [default to null] +**SimpleLeavesQty** | **float64** | | [optional] [default to null] +**LeavesQty** | **float32** | | [optional] [default to null] +**SimpleCumQty** | **float64** | | [optional] [default to null] +**CumQty** | **float32** | | [optional] [default to null] +**AvgPx** | **float64** | | [optional] [default to null] +**Commission** | **float64** | | [optional] [default to null] +**TradePublishIndicator** | **string** | | [optional] [default to null] +**MultiLegReportingType** | **string** | | [optional] [default to null] +**Text** | **string** | | [optional] [default to null] +**TrdMatchID** | **string** | | [optional] [default to null] +**ExecCost** | **float32** | | [optional] [default to null] +**ExecComm** | **float32** | | [optional] [default to null] +**HomeNotional** | **float64** | | [optional] [default to null] +**ForeignNotional** | **float64** | | [optional] [default to null] +**TransactTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/ExecutionApi.md b/docs/ExecutionApi.md new file mode 100644 index 0000000..4189cd5 --- /dev/null +++ b/docs/ExecutionApi.md @@ -0,0 +1,92 @@ +# \ExecutionApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**ExecutionGet**](ExecutionApi.md#ExecutionGet) | **Get** /execution | Get all raw executions for your account. +[**ExecutionGetTradeHistory**](ExecutionApi.md#ExecutionGetTradeHistory) | **Get** /execution/tradeHistory | Get all balance-affecting executions. This includes each trade, insurance charge, and settlement. + + +# **ExecutionGet** +> []Execution ExecutionGet(ctx, optional) +Get all raw executions for your account. + +This returns all raw transactions, which includes order opening and cancelation, and order status changes. It can be quite noisy. More focused information is available at `/execution/tradeHistory`. You may also use the `filter` param to target your query. Specify an array as a filter value, such as `{\"execType\": [\"Settlement\", \"Trade\"]}` to filter on multiple values. See [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_8_8.html) for explanations of these fields. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***ExecutionGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a ExecutionGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Execution**](Execution.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **ExecutionGetTradeHistory** +> []Execution ExecutionGetTradeHistory(ctx, optional) +Get all balance-affecting executions. This includes each trade, insurance charge, and settlement. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***ExecutionGetTradeHistoryOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a ExecutionGetTradeHistoryOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Execution**](Execution.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Funding.md b/docs/Funding.md new file mode 100644 index 0000000..0fc5821 --- /dev/null +++ b/docs/Funding.md @@ -0,0 +1,14 @@ +# Funding + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [default to null] +**FundingInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**FundingRate** | **float64** | | [optional] [default to null] +**FundingRateDaily** | **float64** | | [optional] [default to null] + +[[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/docs/FundingApi.md b/docs/FundingApi.md new file mode 100644 index 0000000..472eab2 --- /dev/null +++ b/docs/FundingApi.md @@ -0,0 +1,49 @@ +# \FundingApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**FundingGet**](FundingApi.md#FundingGet) | **Get** /funding | Get funding history. + + +# **FundingGet** +> []Funding FundingGet(ctx, optional) +Get funding history. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FundingGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a FundingGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Funding**](Funding.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/IndexComposite.md b/docs/IndexComposite.md new file mode 100644 index 0000000..833190b --- /dev/null +++ b/docs/IndexComposite.md @@ -0,0 +1,16 @@ +# IndexComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [optional] [default to null] +**IndexSymbol** | **string** | | [optional] [default to null] +**Reference** | **string** | | [optional] [default to null] +**LastPrice** | **float64** | | [optional] [default to null] +**Weight** | **float64** | | [optional] [default to null] +**Logged** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/InlineResponse200.md b/docs/InlineResponse200.md new file mode 100644 index 0000000..cb01d44 --- /dev/null +++ b/docs/InlineResponse200.md @@ -0,0 +1,10 @@ +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Success** | **bool** | | [optional] [default to null] + +[[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/docs/InlineResponse2001.md b/docs/InlineResponse2001.md new file mode 100644 index 0000000..64abf29 --- /dev/null +++ b/docs/InlineResponse2001.md @@ -0,0 +1,10 @@ +# InlineResponse2001 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] [default to null] + +[[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/docs/Instrument.md b/docs/Instrument.md new file mode 100644 index 0000000..193a312 --- /dev/null +++ b/docs/Instrument.md @@ -0,0 +1,110 @@ +# Instrument + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Symbol** | **string** | | [default to null] +**RootSymbol** | **string** | | [optional] [default to null] +**State** | **string** | | [optional] [default to null] +**Typ** | **string** | | [optional] [default to null] +**Listing** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Front** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Expiry** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Settle** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**RelistInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**InverseLeg** | **string** | | [optional] [default to null] +**SellLeg** | **string** | | [optional] [default to null] +**BuyLeg** | **string** | | [optional] [default to null] +**OptionStrikePcnt** | **float64** | | [optional] [default to null] +**OptionStrikeRound** | **float64** | | [optional] [default to null] +**OptionStrikePrice** | **float64** | | [optional] [default to null] +**OptionMultiplier** | **float64** | | [optional] [default to null] +**PositionCurrency** | **string** | | [optional] [default to null] +**Underlying** | **string** | | [optional] [default to null] +**QuoteCurrency** | **string** | | [optional] [default to null] +**UnderlyingSymbol** | **string** | | [optional] [default to null] +**Reference** | **string** | | [optional] [default to null] +**ReferenceSymbol** | **string** | | [optional] [default to null] +**CalcInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**PublishInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**PublishTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**MaxOrderQty** | **float32** | | [optional] [default to null] +**MaxPrice** | **float64** | | [optional] [default to null] +**LotSize** | **float32** | | [optional] [default to null] +**TickSize** | **float64** | | [optional] [default to null] +**Multiplier** | **float32** | | [optional] [default to null] +**SettlCurrency** | **string** | | [optional] [default to null] +**UnderlyingToPositionMultiplier** | **float32** | | [optional] [default to null] +**UnderlyingToSettleMultiplier** | **float32** | | [optional] [default to null] +**QuoteToSettleMultiplier** | **float32** | | [optional] [default to null] +**IsQuanto** | **bool** | | [optional] [default to null] +**IsInverse** | **bool** | | [optional] [default to null] +**InitMargin** | **float64** | | [optional] [default to null] +**MaintMargin** | **float64** | | [optional] [default to null] +**RiskLimit** | **float32** | | [optional] [default to null] +**RiskStep** | **float32** | | [optional] [default to null] +**Limit** | **float64** | | [optional] [default to null] +**Capped** | **bool** | | [optional] [default to null] +**Taxed** | **bool** | | [optional] [default to null] +**Deleverage** | **bool** | | [optional] [default to null] +**MakerFee** | **float64** | | [optional] [default to null] +**TakerFee** | **float64** | | [optional] [default to null] +**SettlementFee** | **float64** | | [optional] [default to null] +**InsuranceFee** | **float64** | | [optional] [default to null] +**FundingBaseSymbol** | **string** | | [optional] [default to null] +**FundingQuoteSymbol** | **string** | | [optional] [default to null] +**FundingPremiumSymbol** | **string** | | [optional] [default to null] +**FundingTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**FundingInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**FundingRate** | **float64** | | [optional] [default to null] +**IndicativeFundingRate** | **float64** | | [optional] [default to null] +**RebalanceTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**RebalanceInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**OpeningTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**ClosingTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**SessionInterval** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**PrevClosePrice** | **float64** | | [optional] [default to null] +**LimitDownPrice** | **float64** | | [optional] [default to null] +**LimitUpPrice** | **float64** | | [optional] [default to null] +**BankruptLimitDownPrice** | **float64** | | [optional] [default to null] +**BankruptLimitUpPrice** | **float64** | | [optional] [default to null] +**PrevTotalVolume** | **float32** | | [optional] [default to null] +**TotalVolume** | **float32** | | [optional] [default to null] +**Volume** | **float32** | | [optional] [default to null] +**Volume24h** | **float32** | | [optional] [default to null] +**PrevTotalTurnover** | **float32** | | [optional] [default to null] +**TotalTurnover** | **float32** | | [optional] [default to null] +**Turnover** | **float32** | | [optional] [default to null] +**Turnover24h** | **float32** | | [optional] [default to null] +**PrevPrice24h** | **float64** | | [optional] [default to null] +**Vwap** | **float64** | | [optional] [default to null] +**HighPrice** | **float64** | | [optional] [default to null] +**LowPrice** | **float64** | | [optional] [default to null] +**LastPrice** | **float64** | | [optional] [default to null] +**LastPriceProtected** | **float64** | | [optional] [default to null] +**LastTickDirection** | **string** | | [optional] [default to null] +**LastChangePcnt** | **float64** | | [optional] [default to null] +**BidPrice** | **float64** | | [optional] [default to null] +**MidPrice** | **float64** | | [optional] [default to null] +**AskPrice** | **float64** | | [optional] [default to null] +**ImpactBidPrice** | **float64** | | [optional] [default to null] +**ImpactMidPrice** | **float64** | | [optional] [default to null] +**ImpactAskPrice** | **float64** | | [optional] [default to null] +**HasLiquidity** | **bool** | | [optional] [default to null] +**OpenInterest** | **float32** | | [optional] [default to null] +**OpenValue** | **float32** | | [optional] [default to null] +**FairMethod** | **string** | | [optional] [default to null] +**FairBasisRate** | **float64** | | [optional] [default to null] +**FairBasis** | **float64** | | [optional] [default to null] +**FairPrice** | **float64** | | [optional] [default to null] +**MarkMethod** | **string** | | [optional] [default to null] +**MarkPrice** | **float64** | | [optional] [default to null] +**IndicativeTaxRate** | **float64** | | [optional] [default to null] +**IndicativeSettlePrice** | **float64** | | [optional] [default to null] +**OptionUnderlyingPrice** | **float64** | | [optional] [default to null] +**SettledPrice** | **float64** | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/InstrumentApi.md b/docs/InstrumentApi.md new file mode 100644 index 0000000..e1b7b9c --- /dev/null +++ b/docs/InstrumentApi.md @@ -0,0 +1,189 @@ +# \InstrumentApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**InstrumentGet**](InstrumentApi.md#InstrumentGet) | **Get** /instrument | Get instruments. +[**InstrumentGetActive**](InstrumentApi.md#InstrumentGetActive) | **Get** /instrument/active | Get all active instruments and instruments that have expired in <24hrs. +[**InstrumentGetActiveAndIndices**](InstrumentApi.md#InstrumentGetActiveAndIndices) | **Get** /instrument/activeAndIndices | Helper method. Gets all active instruments and all indices. This is a join of the result of /indices and /active. +[**InstrumentGetActiveIntervals**](InstrumentApi.md#InstrumentGetActiveIntervals) | **Get** /instrument/activeIntervals | Return all active contract series and interval pairs. +[**InstrumentGetCompositeIndex**](InstrumentApi.md#InstrumentGetCompositeIndex) | **Get** /instrument/compositeIndex | Show constituent parts of an index. +[**InstrumentGetIndices**](InstrumentApi.md#InstrumentGetIndices) | **Get** /instrument/indices | Get all price indices. + + +# **InstrumentGet** +> []Instrument InstrumentGet(ctx, optional) +Get instruments. + +This returns all instruments and indices, including those that have settled or are unlisted. Use this endpoint if you want to query for individual instruments or use a complex filter. Use `/instrument/active` to return active instruments, or use a filter like `{\"state\": \"Open\"}`. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***InstrumentGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a InstrumentGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Instrument**](Instrument.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **InstrumentGetActive** +> []Instrument InstrumentGetActive(ctx, ) +Get all active instruments and instruments that have expired in <24hrs. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Instrument**](Instrument.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **InstrumentGetActiveAndIndices** +> []Instrument InstrumentGetActiveAndIndices(ctx, ) +Helper method. Gets all active instruments and all indices. This is a join of the result of /indices and /active. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Instrument**](Instrument.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **InstrumentGetActiveIntervals** +> InstrumentInterval InstrumentGetActiveIntervals(ctx, ) +Return all active contract series and interval pairs. + +This endpoint is useful for determining which pairs are live. It returns two arrays of strings. The first is intervals, such as `[\"XBT:perpetual\", \"XBT:monthly\", \"XBT:quarterly\", \"ETH:monthly\", ...]`. These identifiers are usable in any query's `symbol` param. The second array is the current resolution of these intervals. Results are mapped at the same index. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**InstrumentInterval**](InstrumentInterval.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **InstrumentGetCompositeIndex** +> []IndexComposite InstrumentGetCompositeIndex(ctx, optional) +Show constituent parts of an index. + +Composite indices are built from multiple external price sources. Use this endpoint to get the underlying prices of an index. For example, send a `symbol` of `.XBT` to get the ticks and weights of the constituent exchanges that build the \".XBT\" index. A tick with reference `\"BMI\"` and weight `null` is the composite index tick. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***InstrumentGetCompositeIndexOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a InstrumentGetCompositeIndexOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account** | **optional.Float64**| | + **symbol** | **optional.String**| The composite index symbol. | [default to .XBT] + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]IndexComposite**](IndexComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **InstrumentGetIndices** +> []Instrument InstrumentGetIndices(ctx, ) +Get all price indices. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Instrument**](Instrument.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/InstrumentInterval.md b/docs/InstrumentInterval.md new file mode 100644 index 0000000..4083078 --- /dev/null +++ b/docs/InstrumentInterval.md @@ -0,0 +1,11 @@ +# InstrumentInterval + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Intervals** | **[]string** | | [default to null] +**Symbols** | **[]string** | | [default to null] + +[[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/docs/Insurance.md b/docs/Insurance.md new file mode 100644 index 0000000..2824169 --- /dev/null +++ b/docs/Insurance.md @@ -0,0 +1,12 @@ +# Insurance + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Currency** | **string** | | [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**WalletBalance** | **float32** | | [optional] [default to null] + +[[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/docs/InsuranceApi.md b/docs/InsuranceApi.md new file mode 100644 index 0000000..cbbe322 --- /dev/null +++ b/docs/InsuranceApi.md @@ -0,0 +1,49 @@ +# \InsuranceApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**InsuranceGet**](InsuranceApi.md#InsuranceGet) | **Get** /insurance | Get insurance fund history. + + +# **InsuranceGet** +> []Insurance InsuranceGet(ctx, optional) +Get insurance fund history. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***InsuranceGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a InsuranceGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Insurance**](Insurance.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Leaderboard.md b/docs/Leaderboard.md new file mode 100644 index 0000000..af57354 --- /dev/null +++ b/docs/Leaderboard.md @@ -0,0 +1,12 @@ +# Leaderboard + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [default to null] +**IsRealName** | **bool** | | [optional] [default to null] +**Profit** | **float64** | | [optional] [default to null] + +[[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/docs/LeaderboardApi.md b/docs/LeaderboardApi.md new file mode 100644 index 0000000..dab6870 --- /dev/null +++ b/docs/LeaderboardApi.md @@ -0,0 +1,65 @@ +# \LeaderboardApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**LeaderboardGet**](LeaderboardApi.md#LeaderboardGet) | **Get** /leaderboard | Get current leaderboard. +[**LeaderboardGetName**](LeaderboardApi.md#LeaderboardGetName) | **Get** /leaderboard/name | Get your alias on the leaderboard. + + +# **LeaderboardGet** +> []Leaderboard LeaderboardGet(ctx, optional) +Get current leaderboard. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***LeaderboardGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a LeaderboardGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **method** | **optional.String**| Ranking type. Options: \"notional\", \"ROE\" | [default to notional] + +### Return type + +[**[]Leaderboard**](Leaderboard.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **LeaderboardGetName** +> InlineResponse2001 LeaderboardGetName(ctx, ) +Get your alias on the leaderboard. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**InlineResponse2001**](inline_response_200_1.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Liquidation.md b/docs/Liquidation.md new file mode 100644 index 0000000..60aea3e --- /dev/null +++ b/docs/Liquidation.md @@ -0,0 +1,14 @@ +# Liquidation + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**OrderID** | **string** | | [default to null] +**Symbol** | **string** | | [optional] [default to null] +**Side** | **string** | | [optional] [default to null] +**Price** | **float64** | | [optional] [default to null] +**LeavesQty** | **float32** | | [optional] [default to null] + +[[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/docs/LiquidationApi.md b/docs/LiquidationApi.md new file mode 100644 index 0000000..5a0a0b5 --- /dev/null +++ b/docs/LiquidationApi.md @@ -0,0 +1,49 @@ +# \LiquidationApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**LiquidationGet**](LiquidationApi.md#LiquidationGet) | **Get** /liquidation | Get liquidation orders. + + +# **LiquidationGet** +> []Liquidation LiquidationGet(ctx, optional) +Get liquidation orders. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***LiquidationGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a LiquidationGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Liquidation**](Liquidation.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Margin.md b/docs/Margin.md new file mode 100644 index 0000000..541971c --- /dev/null +++ b/docs/Margin.md @@ -0,0 +1,50 @@ +# Margin + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Account** | **float32** | | [default to null] +**Currency** | **string** | | [default to null] +**RiskLimit** | **float32** | | [optional] [default to null] +**PrevState** | **string** | | [optional] [default to null] +**State** | **string** | | [optional] [default to null] +**Action** | **string** | | [optional] [default to null] +**Amount** | **float32** | | [optional] [default to null] +**PendingCredit** | **float32** | | [optional] [default to null] +**PendingDebit** | **float32** | | [optional] [default to null] +**ConfirmedDebit** | **float32** | | [optional] [default to null] +**PrevRealisedPnl** | **float32** | | [optional] [default to null] +**PrevUnrealisedPnl** | **float32** | | [optional] [default to null] +**GrossComm** | **float32** | | [optional] [default to null] +**GrossOpenCost** | **float32** | | [optional] [default to null] +**GrossOpenPremium** | **float32** | | [optional] [default to null] +**GrossExecCost** | **float32** | | [optional] [default to null] +**GrossMarkValue** | **float32** | | [optional] [default to null] +**RiskValue** | **float32** | | [optional] [default to null] +**TaxableMargin** | **float32** | | [optional] [default to null] +**InitMargin** | **float32** | | [optional] [default to null] +**MaintMargin** | **float32** | | [optional] [default to null] +**SessionMargin** | **float32** | | [optional] [default to null] +**TargetExcessMargin** | **float32** | | [optional] [default to null] +**VarMargin** | **float32** | | [optional] [default to null] +**RealisedPnl** | **float32** | | [optional] [default to null] +**UnrealisedPnl** | **float32** | | [optional] [default to null] +**IndicativeTax** | **float32** | | [optional] [default to null] +**UnrealisedProfit** | **float32** | | [optional] [default to null] +**SyntheticMargin** | **float32** | | [optional] [default to null] +**WalletBalance** | **float32** | | [optional] [default to null] +**MarginBalance** | **float32** | | [optional] [default to null] +**MarginBalancePcnt** | **float64** | | [optional] [default to 0.0] +**MarginLeverage** | **float64** | | [optional] [default to 0.0] +**MarginUsedPcnt** | **float64** | | [optional] [default to 0.0] +**ExcessMargin** | **float32** | | [optional] [default to null] +**ExcessMarginPcnt** | **float64** | | [optional] [default to 0.0] +**AvailableMargin** | **float32** | | [optional] [default to null] +**WithdrawableMargin** | **float32** | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**GrossLastValue** | **float32** | | [optional] [default to null] +**Commission** | **float64** | | [optional] [default to 0.0] + +[[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/docs/ModelError.md b/docs/ModelError.md new file mode 100644 index 0000000..b4cda5d --- /dev/null +++ b/docs/ModelError.md @@ -0,0 +1,10 @@ +# ModelError + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Error_** | [***ErrorError**](Error_error.md) | | [default to null] + +[[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/docs/Notification.md b/docs/Notification.md new file mode 100644 index 0000000..7cc1cf7 --- /dev/null +++ b/docs/Notification.md @@ -0,0 +1,19 @@ +# Notification + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **float32** | | [optional] [default to null] +**Date** | [**time.Time**](time.Time.md) | | [default to null] +**Title** | **string** | | [default to null] +**Body** | **string** | | [default to null] +**Ttl** | **float32** | | [default to null] +**Type_** | **string** | | [optional] [default to null] +**Closable** | **bool** | | [optional] [default to null] +**Persist** | **bool** | | [optional] [default to null] +**WaitForVisibility** | **bool** | | [optional] [default to null] +**Sound** | **string** | | [optional] [default to null] + +[[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/docs/NotificationApi.md b/docs/NotificationApi.md new file mode 100644 index 0000000..c9351b3 --- /dev/null +++ b/docs/NotificationApi.md @@ -0,0 +1,33 @@ +# \NotificationApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**NotificationGet**](NotificationApi.md#NotificationGet) | **Get** /notification | Get your current notifications. + + +# **NotificationGet** +> []Notification NotificationGet(ctx, ) +Get your current notifications. + +This is an upcoming feature and currently does not return data. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Notification**](Notification.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Order.md b/docs/Order.md new file mode 100644 index 0000000..cf5e3a3 --- /dev/null +++ b/docs/Order.md @@ -0,0 +1,42 @@ +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**OrderID** | **string** | | [default to null] +**ClOrdID** | **string** | | [optional] [default to null] +**ClOrdLinkID** | **string** | | [optional] [default to null] +**Account** | **float32** | | [optional] [default to null] +**Symbol** | **string** | | [optional] [default to null] +**Side** | **string** | | [optional] [default to null] +**SimpleOrderQty** | **float64** | | [optional] [default to null] +**OrderQty** | **float32** | | [optional] [default to null] +**Price** | **float64** | | [optional] [default to null] +**DisplayQty** | **float32** | | [optional] [default to null] +**StopPx** | **float64** | | [optional] [default to null] +**PegOffsetValue** | **float64** | | [optional] [default to null] +**PegPriceType** | **string** | | [optional] [default to null] +**Currency** | **string** | | [optional] [default to null] +**SettlCurrency** | **string** | | [optional] [default to null] +**OrdType** | **string** | | [optional] [default to null] +**TimeInForce** | **string** | | [optional] [default to null] +**ExecInst** | **string** | | [optional] [default to null] +**ContingencyType** | **string** | | [optional] [default to null] +**ExDestination** | **string** | | [optional] [default to null] +**OrdStatus** | **string** | | [optional] [default to null] +**Triggered** | **string** | | [optional] [default to null] +**WorkingIndicator** | **bool** | | [optional] [default to null] +**OrdRejReason** | **string** | | [optional] [default to null] +**SimpleLeavesQty** | **float64** | | [optional] [default to null] +**LeavesQty** | **float32** | | [optional] [default to null] +**SimpleCumQty** | **float64** | | [optional] [default to null] +**CumQty** | **float32** | | [optional] [default to null] +**AvgPx** | **float64** | | [optional] [default to null] +**MultiLegReportingType** | **string** | | [optional] [default to null] +**Text** | **string** | | [optional] [default to null] +**TransactTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/OrderApi.md b/docs/OrderApi.md new file mode 100644 index 0000000..78fb48c --- /dev/null +++ b/docs/OrderApi.md @@ -0,0 +1,362 @@ +# \OrderApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**OrderAmend**](OrderApi.md#OrderAmend) | **Put** /order | Amend the quantity or price of an open order. +[**OrderAmendBulk**](OrderApi.md#OrderAmendBulk) | **Put** /order/bulk | Amend multiple orders for the same symbol. +[**OrderCancel**](OrderApi.md#OrderCancel) | **Delete** /order | Cancel order(s). Send multiple order IDs to cancel in bulk. +[**OrderCancelAll**](OrderApi.md#OrderCancelAll) | **Delete** /order/all | Cancels all of your orders. +[**OrderCancelAllAfter**](OrderApi.md#OrderCancelAllAfter) | **Post** /order/cancelAllAfter | Automatically cancel all your orders after a specified timeout. +[**OrderClosePosition**](OrderApi.md#OrderClosePosition) | **Post** /order/closePosition | Close a position. [Deprecated, use POST /order with execInst: 'Close'] +[**OrderGetOrders**](OrderApi.md#OrderGetOrders) | **Get** /order | Get your orders. +[**OrderNew**](OrderApi.md#OrderNew) | **Post** /order | Create a new order. +[**OrderNewBulk**](OrderApi.md#OrderNewBulk) | **Post** /order/bulk | Create multiple new orders for the same symbol. + + +# **OrderAmend** +> Order OrderAmend(ctx, optional) +Amend the quantity or price of an open order. + +Send an `orderID` or `origClOrdID` to identify the order you wish to amend. Both order quantity and price can be amended. Only one `qty` field can be used to amend. Use the `leavesQty` field to specify how much of the order you wish to remain open. This can be useful if you want to adjust your position's delta by a certain amount, regardless of how much of the order has already filled. > A `leavesQty` can be used to make a \"Filled\" order live again, if it is received within 60 seconds of the fill. Use the `simpleOrderQty` and `simpleLeavesQty` fields to specify order size in Bitcoin, rather than contracts. These fields will round up to the nearest contract. Like order placement, amending can be done in bulk. Simply send a request to `PUT /api/v1/order/bulk` with a JSON body of the shape: `{\"orders\": [{...}, {...}]}`, each object containing the fields used in this endpoint. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderAmendOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderAmendOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderID** | **optional.String**| Order ID | + **origClOrdID** | **optional.String**| Client Order ID. See POST /order. | + **clOrdID** | **optional.String**| Optional new Client Order ID, requires `origClOrdID`. | + **simpleOrderQty** | **optional.Float64**| Optional order quantity in units of the underlying instrument (i.e. Bitcoin). | + **orderQty** | **optional.Float32**| Optional order quantity in units of the instrument (i.e. contracts). | + **simpleLeavesQty** | **optional.Float64**| Optional leaves quantity in units of the underlying instrument (i.e. Bitcoin). Useful for amending partially filled orders. | + **leavesQty** | **optional.Float32**| Optional leaves quantity in units of the instrument (i.e. contracts). Useful for amending partially filled orders. | + **price** | **optional.Float64**| Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched' orders. | + **stopPx** | **optional.Float64**| Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. Use a price below the current price for stop-sell orders and buy-if-touched orders. | + **pegOffsetValue** | **optional.Float64**| Optional trailing offset from the current price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative offset for stop-sell orders and buy-if-touched orders. Optional offset from the peg price for 'Pegged' orders. | + **text** | **optional.String**| Optional amend annotation. e.g. 'Adjust skew'. | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderAmendBulk** +> []Order OrderAmendBulk(ctx, optional) +Amend multiple orders for the same symbol. + +Similar to POST /amend, but with multiple orders. `application/json` only. Ratelimited at 10%. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderAmendBulkOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderAmendBulkOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orders** | **optional.String**| An array of orders. | + +### Return type + +[**[]Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderCancel** +> []Order OrderCancel(ctx, optional) +Cancel order(s). Send multiple order IDs to cancel in bulk. + +Either an orderID or a clOrdID must be provided. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderCancelOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderCancelOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderID** | **optional.String**| Order ID(s). | + **clOrdID** | **optional.String**| Client Order ID(s). See POST /order. | + **text** | **optional.String**| Optional cancellation annotation. e.g. 'Spread Exceeded'. | + +### Return type + +[**[]Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderCancelAll** +> []Order OrderCancelAll(ctx, optional) +Cancels all of your orders. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderCancelAllOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderCancelAllOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Optional symbol. If provided, only cancels orders for that symbol. | + **filter** | **optional.String**| Optional filter for cancellation. Use to only cancel some orders, e.g. `{\"side\": \"Buy\"}`. | + **text** | **optional.String**| Optional cancellation annotation. e.g. 'Spread Exceeded' | + +### Return type + +[**[]Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderCancelAllAfter** +> interface{} OrderCancelAllAfter(ctx, timeout) +Automatically cancel all your orders after a specified timeout. + +Useful as a dead-man's switch to ensure your orders are canceled in case of an outage. If called repeatedly, the existing offset will be canceled and a new one will be inserted in its place. Example usage: call this route at 15s intervals with an offset of 60000 (60s). If this route is not called within 60 seconds, all your orders will be automatically canceled. This is also available via [WebSocket](https://www.bitmex.com/app/wsAPI#Dead-Mans-Switch-Auto-Cancel). + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **timeout** | **float64**| Timeout in ms. Set to 0 to cancel this timer. | + +### Return type + +[**interface{}**](interface{}.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderClosePosition** +> Order OrderClosePosition(ctx, symbol, optional) +Close a position. [Deprecated, use POST /order with execInst: 'Close'] + +If no `price` is specified, a market order will be submitted to close the whole of your position. This will also close all other open orders in this symbol. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Symbol of position to close. | + **optional** | ***OrderClosePositionOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderClosePositionOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **price** | **optional.Float64**| Optional limit price. | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderGetOrders** +> []Order OrderGetOrders(ctx, optional) +Get your orders. + +To get open orders only, send {\"open\": true} in the filter param. See the FIX Spec for explanations of these fields. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderGetOrdersOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderGetOrdersOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderNew** +> Order OrderNew(ctx, symbol, optional) +Create a new order. + +## Placing Orders This endpoint is used for placing orders. See individual fields below for more details on their use. #### Order Types All orders require a `symbol`. All other fields are optional except when otherwise specified. These are the valid `ordType`s: * **Limit**: The default order type. Specify an `orderQty` and `price`. * **Market**: A traditional Market order. A Market order will execute until filled or your bankruptcy price is reached, at which point it will cancel. * **MarketWithLeftOverAsLimit**: A market order that, after eating through the order book as far as permitted by available margin, will become a limit order. The difference between this type and `Market` only affects the behavior in thin books. Upon reaching the deepest possible price, if there is quantity left over, a `Market` order will cancel the remaining quantity. `MarketWithLeftOverAsLimit` will keep the remaining quantity in the books as a `Limit`. * **Stop**: A Stop Market order. Specify an `orderQty` and `stopPx`. When the `stopPx` is reached, the order will be entered into the book. * On sell orders, the order will trigger if the triggering price is lower than the `stopPx`. On buys, higher. * Note: Stop orders do not consume margin until triggered. Be sure that the required margin is available in your account so that it may trigger fully. * `Close` Stops don't require an `orderQty`. See Execution Instructions below. * **StopLimit**: Like a Stop Market, but enters a Limit order instead of a Market order. Specify an `orderQty`, `stopPx`, and `price`. * **MarketIfTouched**: Similar to a Stop, but triggers are done in the opposite direction. Useful for Take Profit orders. * **LimitIfTouched**: As above; use for Take Profit Limit orders. #### Execution Instructions The following `execInst`s are supported. If using multiple, separate with a comma (e.g. `LastPrice,Close`). * **ParticipateDoNotInitiate**: Also known as a Post-Only order. If this order would have executed on placement, it will cancel instead. * **AllOrNone**: Valid only for hidden orders (`displayQty: 0`). Use to only execute if the entire order would fill. * **MarkPrice, LastPrice, IndexPrice**: Used by stop and if-touched orders to determine the triggering price. Use only one. By default, `'MarkPrice'` is used. Also used for Pegged orders to define the value of `'LastPeg'`. * **ReduceOnly**: A `'ReduceOnly'` order can only reduce your position, not increase it. If you have a `'ReduceOnly'` limit order that rests in the order book while the position is reduced by other orders, then its order quantity will be amended down or canceled. If there are multiple `'ReduceOnly'` orders the least agresssive will be amended first. * **Close**: `'Close'` implies `'ReduceOnly'`. A `'Close'` order will cancel other active limit orders with the same side and symbol if the open quantity exceeds the current position. This is useful for stops: by canceling these orders, a `'Close'` Stop is ensured to have the margin required to execute, and can only execute up to the full size of your position. If `orderQty` is not specified, a `'Close'` order has an `orderQty` equal to your current position's size. * Note that a `Close` order without an `orderQty` requires a `side`, so that BitMEX knows if it should trigger above or below the `stopPx`. #### Linked Orders Linked Orders are an advanced capability. It is very powerful, but its use requires careful coding and testing. Please follow this document carefully and use the [Testnet Exchange](https://testnet.bitmex.com) while developing. BitMEX offers four advanced Linked Order types: * **OCO**: *One Cancels the Other*. A very flexible version of the standard Stop / Take Profit technique. Multiple orders may be linked together using a single `clOrdLinkID`. Send a `contingencyType` of `OneCancelsTheOther` on the orders. The first order that fully or partially executes (or activates for `Stop` orders) will cancel all other orders with the same `clOrdLinkID`. * **OTO**: *One Triggers the Other*. Send a `contingencyType` of `'OneTriggersTheOther'` on the primary order and then subsequent orders with the same `clOrdLinkID` will be not be triggered until the primary order fully executes. * **OUOA**: *One Updates the Other Absolute*. Send a `contingencyType` of `'OneUpdatesTheOtherAbsolute'` on the orders. Then as one order has a execution, other orders with the same `clOrdLinkID` will have their order quantity amended down by the execution quantity. * **OUOP**: *One Updates the Other Proportional*. Send a `contingencyType` of `'OneUpdatesTheOtherProportional'` on the orders. Then as one order has a execution, other orders with the same `clOrdLinkID` will have their order quantity reduced proportionally by the fill percentage. #### Trailing Stops You may use `pegPriceType` of `'TrailingStopPeg'` to create Trailing Stops. The pegged `stopPx` will move as the market moves away from the peg, and freeze as the market moves toward it. To use, combine with `pegOffsetValue` to set the `stopPx` of your order. The peg is set to the triggering price specified in the `execInst` (default `'MarkPrice'`). Use a negative offset for stop-sell and buy-if-touched orders. Requires `ordType`: `'Stop', 'StopLimit', 'MarketIfTouched', 'LimitIfTouched'`. #### Simple Quantities Send a `simpleOrderQty` instead of an `orderQty` to create an order denominated in the underlying currency. This is useful for opening up a position with 1 XBT of exposure without having to calculate how many contracts it is. #### Rate Limits See the [Bulk Order Documentation](#!/Order/Order_newBulk) if you need to place multiple orders at the same time. Bulk orders require fewer risk checks in the trading engine and thus are ratelimited at **1/10** the normal rate. You can also improve your reactivity to market movements while staying under your ratelimit by using the [Amend](#!/Order/Order_amend) and [Amend Bulk](#!/Order/Order_amendBulk) endpoints. This allows you to stay in the market and avoids the cancel/replace cycle. #### Tracking Your Orders If you want to keep track of order IDs yourself, set a unique `clOrdID` per order. This `clOrdID` will come back as a property on the order and any related executions (including on the WebSocket), and can be used to get or cancel the order. Max length is 36 characters. You can also change the `clOrdID` by amending an order, supplying an `origClOrdID`, and your desired new ID as the `clOrdID` param, like so: ``` # Amends an order's leavesQty, and updates its clOrdID to \"def-456\" PUT /api/v1/order {\"origClOrdID\": \"abc-123\", \"clOrdID\": \"def-456\", \"leavesQty\": 1000} ``` + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Instrument symbol. e.g. 'XBTUSD'. | + **optional** | ***OrderNewOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderNewOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **side** | **optional.String**| Order side. Valid options: Buy, Sell. Defaults to 'Buy' unless `orderQty` or `simpleOrderQty` is negative. | + **simpleOrderQty** | **optional.Float64**| Order quantity in units of the underlying instrument (i.e. Bitcoin). | + **orderQty** | **optional.Float32**| Order quantity in units of the instrument (i.e. contracts). | + **price** | **optional.Float64**| Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched' orders. | + **displayQty** | **optional.Float32**| Optional quantity to display in the book. Use 0 for a fully hidden order. | + **stopPx** | **optional.Float64**| Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. Use a price below the current price for stop-sell orders and buy-if-touched orders. Use `execInst` of 'MarkPrice' or 'LastPrice' to define the current price used for triggering. | + **clOrdID** | **optional.String**| Optional Client Order ID. This clOrdID will come back on the order and any related executions. | + **clOrdLinkID** | **optional.String**| Optional Client Order Link ID for contingent orders. | + **pegOffsetValue** | **optional.Float64**| Optional trailing offset from the current price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative offset for stop-sell orders and buy-if-touched orders. Optional offset from the peg price for 'Pegged' orders. | + **pegPriceType** | **optional.String**| Optional peg price type. Valid options: LastPeg, MidPricePeg, MarketPeg, PrimaryPeg, TrailingStopPeg. | + **ordType** | **optional.String**| Order type. Valid options: Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, Pegged. Defaults to 'Limit' when `price` is specified. Defaults to 'Stop' when `stopPx` is specified. Defaults to 'StopLimit' when `price` and `stopPx` are specified. | [default to Limit] + **timeInForce** | **optional.String**| Time in force. Valid options: Day, GoodTillCancel, ImmediateOrCancel, FillOrKill. Defaults to 'GoodTillCancel' for 'Limit', 'StopLimit', 'LimitIfTouched', and 'MarketWithLeftOverAsLimit' orders. | + **execInst** | **optional.String**| Optional execution instructions. Valid options: ParticipateDoNotInitiate, AllOrNone, MarkPrice, IndexPrice, LastPrice, Close, ReduceOnly, Fixed. 'AllOrNone' instruction requires `displayQty` to be 0. 'MarkPrice', 'IndexPrice' or 'LastPrice' instruction valid for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. | + **contingencyType** | **optional.String**| Optional contingency type for use with `clOrdLinkID`. Valid options: OneCancelsTheOther, OneTriggersTheOther, OneUpdatesTheOtherAbsolute, OneUpdatesTheOtherProportional. | + **text** | **optional.String**| Optional order annotation. e.g. 'Take profit'. | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **OrderNewBulk** +> []Order OrderNewBulk(ctx, optional) +Create multiple new orders for the same symbol. + +This endpoint is used for placing bulk orders. Valid order types are Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, and Pegged. Each individual order object in the array should have the same properties as an individual POST /order call. This endpoint is much faster for getting many orders into the book at once. Because it reduces load on BitMEX systems, this endpoint is ratelimited at `ceil(0.1 * orders)`. Submitting 10 orders via a bulk order call will only count as 1 request, 15 as 2, 32 as 4, and so on. For now, only `application/json` is supported on this endpoint. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***OrderNewBulkOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderNewBulkOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orders** | **optional.String**| An array of orders. | + +### Return type + +[**[]Order**](Order.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/OrderBookApi.md b/docs/OrderBookApi.md new file mode 100644 index 0000000..764c625 --- /dev/null +++ b/docs/OrderBookApi.md @@ -0,0 +1,44 @@ +# \OrderBookApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**OrderBookGetL2**](OrderBookApi.md#OrderBookGetL2) | **Get** /orderBook/L2 | Get current orderbook in vertical format. + + +# **OrderBookGetL2** +> []OrderBookL2 OrderBookGetL2(ctx, symbol, optional) +Get current orderbook in vertical format. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Instrument symbol. Send a series (e.g. XBT) to get data for the nearest contract in that series. | + **optional** | ***OrderBookGetL2Opts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a OrderBookGetL2Opts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **depth** | **optional.Float32**| Orderbook depth per side. Send 0 for full depth. | [default to 25] + +### Return type + +[**[]OrderBookL2**](OrderBookL2.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/OrderBookL2.md b/docs/OrderBookL2.md new file mode 100644 index 0000000..b310c7b --- /dev/null +++ b/docs/OrderBookL2.md @@ -0,0 +1,14 @@ +# OrderBookL2 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Symbol** | **string** | | [default to null] +**Id** | **float32** | | [default to null] +**Side** | **string** | | [default to null] +**Size** | **float32** | | [optional] [default to null] +**Price** | **float64** | | [optional] [default to null] + +[[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/docs/Position.md b/docs/Position.md new file mode 100644 index 0000000..fdb80c0 --- /dev/null +++ b/docs/Position.md @@ -0,0 +1,100 @@ +# Position + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Account** | **float32** | | [default to null] +**Symbol** | **string** | | [default to null] +**Currency** | **string** | | [default to null] +**Underlying** | **string** | | [optional] [default to null] +**QuoteCurrency** | **string** | | [optional] [default to null] +**Commission** | **float64** | | [optional] [default to 0.0] +**InitMarginReq** | **float64** | | [optional] [default to 0.0] +**MaintMarginReq** | **float64** | | [optional] [default to 0.0] +**RiskLimit** | **float32** | | [optional] [default to null] +**Leverage** | **float64** | | [optional] [default to 0.0] +**CrossMargin** | **bool** | | [optional] [default to null] +**DeleveragePercentile** | **float64** | | [optional] [default to 0.0] +**RebalancedPnl** | **float32** | | [optional] [default to null] +**PrevRealisedPnl** | **float32** | | [optional] [default to null] +**PrevUnrealisedPnl** | **float32** | | [optional] [default to null] +**PrevClosePrice** | **float64** | | [optional] [default to 0.0] +**OpeningTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**OpeningQty** | **float32** | | [optional] [default to null] +**OpeningCost** | **float32** | | [optional] [default to null] +**OpeningComm** | **float32** | | [optional] [default to null] +**OpenOrderBuyQty** | **float32** | | [optional] [default to null] +**OpenOrderBuyCost** | **float32** | | [optional] [default to null] +**OpenOrderBuyPremium** | **float32** | | [optional] [default to null] +**OpenOrderSellQty** | **float32** | | [optional] [default to null] +**OpenOrderSellCost** | **float32** | | [optional] [default to null] +**OpenOrderSellPremium** | **float32** | | [optional] [default to null] +**ExecBuyQty** | **float32** | | [optional] [default to null] +**ExecBuyCost** | **float32** | | [optional] [default to null] +**ExecSellQty** | **float32** | | [optional] [default to null] +**ExecSellCost** | **float32** | | [optional] [default to null] +**ExecQty** | **float32** | | [optional] [default to null] +**ExecCost** | **float32** | | [optional] [default to null] +**ExecComm** | **float32** | | [optional] [default to null] +**CurrentTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**CurrentQty** | **float32** | | [optional] [default to null] +**CurrentCost** | **float32** | | [optional] [default to null] +**CurrentComm** | **float32** | | [optional] [default to null] +**RealisedCost** | **float32** | | [optional] [default to null] +**UnrealisedCost** | **float32** | | [optional] [default to null] +**GrossOpenCost** | **float32** | | [optional] [default to null] +**GrossOpenPremium** | **float32** | | [optional] [default to null] +**GrossExecCost** | **float32** | | [optional] [default to null] +**IsOpen** | **bool** | | [optional] [default to null] +**MarkPrice** | **float64** | | [optional] [default to 0.0] +**MarkValue** | **float32** | | [optional] [default to null] +**RiskValue** | **float32** | | [optional] [default to null] +**HomeNotional** | **float64** | | [optional] [default to 0.0] +**ForeignNotional** | **float64** | | [optional] [default to 0.0] +**PosState** | **string** | | [optional] [default to null] +**PosCost** | **float32** | | [optional] [default to null] +**PosCost2** | **float32** | | [optional] [default to null] +**PosCross** | **float32** | | [optional] [default to null] +**PosInit** | **float32** | | [optional] [default to null] +**PosComm** | **float32** | | [optional] [default to null] +**PosLoss** | **float32** | | [optional] [default to null] +**PosMargin** | **float32** | | [optional] [default to null] +**PosMaint** | **float32** | | [optional] [default to null] +**PosAllowance** | **float32** | | [optional] [default to null] +**TaxableMargin** | **float32** | | [optional] [default to null] +**InitMargin** | **float32** | | [optional] [default to null] +**MaintMargin** | **float32** | | [optional] [default to null] +**SessionMargin** | **float32** | | [optional] [default to null] +**TargetExcessMargin** | **float32** | | [optional] [default to null] +**VarMargin** | **float32** | | [optional] [default to null] +**RealisedGrossPnl** | **float32** | | [optional] [default to null] +**RealisedTax** | **float32** | | [optional] [default to null] +**RealisedPnl** | **float32** | | [optional] [default to null] +**UnrealisedGrossPnl** | **float32** | | [optional] [default to null] +**LongBankrupt** | **float32** | | [optional] [default to null] +**ShortBankrupt** | **float32** | | [optional] [default to null] +**TaxBase** | **float32** | | [optional] [default to null] +**IndicativeTaxRate** | **float64** | | [optional] [default to 0.0] +**IndicativeTax** | **float32** | | [optional] [default to null] +**UnrealisedTax** | **float32** | | [optional] [default to null] +**UnrealisedPnl** | **float32** | | [optional] [default to null] +**UnrealisedPnlPcnt** | **float64** | | [optional] [default to 0.0] +**UnrealisedRoePcnt** | **float64** | | [optional] [default to 0.0] +**SimpleQty** | **float64** | | [optional] [default to 0.0] +**SimpleCost** | **float64** | | [optional] [default to 0.0] +**SimpleValue** | **float64** | | [optional] [default to 0.0] +**SimplePnl** | **float64** | | [optional] [default to 0.0] +**SimplePnlPcnt** | **float64** | | [optional] [default to 0.0] +**AvgCostPrice** | **float64** | | [optional] [default to 0.0] +**AvgEntryPrice** | **float64** | | [optional] [default to 0.0] +**BreakEvenPrice** | **float64** | | [optional] [default to 0.0] +**MarginCallPrice** | **float64** | | [optional] [default to 0.0] +**LiquidationPrice** | **float64** | | [optional] [default to 0.0] +**BankruptPrice** | **float64** | | [optional] [default to 0.0] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**LastPrice** | **float64** | | [optional] [default to 0.0] +**LastValue** | **float32** | | [optional] [default to null] + +[[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/docs/PositionApi.md b/docs/PositionApi.md new file mode 100644 index 0000000..55d690b --- /dev/null +++ b/docs/PositionApi.md @@ -0,0 +1,166 @@ +# \PositionApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**PositionGet**](PositionApi.md#PositionGet) | **Get** /position | Get your positions. +[**PositionIsolateMargin**](PositionApi.md#PositionIsolateMargin) | **Post** /position/isolate | Enable isolated margin or cross margin per-position. +[**PositionTransferIsolatedMargin**](PositionApi.md#PositionTransferIsolatedMargin) | **Post** /position/transferMargin | Transfer equity in or out of a position. +[**PositionUpdateLeverage**](PositionApi.md#PositionUpdateLeverage) | **Post** /position/leverage | Choose leverage for a position. +[**PositionUpdateRiskLimit**](PositionApi.md#PositionUpdateRiskLimit) | **Post** /position/riskLimit | Update your risk limit. + + +# **PositionGet** +> []Position PositionGet(ctx, optional) +Get your positions. + +See the FIX Spec for explanations of these fields. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***PositionGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a PositionGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **filter** | **optional.String**| Table filter. For example, send {\"symbol\": \"XBTUSD\"}. | + **columns** | **optional.String**| Which columns to fetch. For example, send [\"columnName\"]. | + **count** | **optional.Float32**| Number of rows to fetch. | + +### Return type + +[**[]Position**](Position.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **PositionIsolateMargin** +> Position PositionIsolateMargin(ctx, symbol, optional) +Enable isolated margin or cross margin per-position. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Position symbol to isolate. | + **optional** | ***PositionIsolateMarginOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a PositionIsolateMarginOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **enabled** | **optional.Bool**| True for isolated margin, false for cross margin. | [default to true] + +### Return type + +[**Position**](Position.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **PositionTransferIsolatedMargin** +> Position PositionTransferIsolatedMargin(ctx, symbol, amount) +Transfer equity in or out of a position. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Symbol of position to isolate. | + **amount** | **float32**| Amount to transfer, in Satoshis. May be negative. | + +### Return type + +[**Position**](Position.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **PositionUpdateLeverage** +> Position PositionUpdateLeverage(ctx, symbol, leverage) +Choose leverage for a position. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Symbol of position to adjust. | + **leverage** | **float64**| Leverage value. Send a number between 0.01 and 100 to enable isolated margin with a fixed leverage. Send 0 to enable cross margin. | + +### Return type + +[**Position**](Position.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **PositionUpdateRiskLimit** +> Position PositionUpdateRiskLimit(ctx, symbol, riskLimit) +Update your risk limit. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **symbol** | **string**| Symbol of position to update risk limit on. | + **riskLimit** | **float32**| New Risk Limit, in Satoshis. | + +### Return type + +[**Position**](Position.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Quote.md b/docs/Quote.md new file mode 100644 index 0000000..1a9d6e5 --- /dev/null +++ b/docs/Quote.md @@ -0,0 +1,15 @@ +# Quote + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [default to null] +**BidSize** | **float32** | | [optional] [default to null] +**BidPrice** | **float64** | | [optional] [default to null] +**AskPrice** | **float64** | | [optional] [default to null] +**AskSize** | **float32** | | [optional] [default to null] + +[[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/docs/QuoteApi.md b/docs/QuoteApi.md new file mode 100644 index 0000000..90cf5a7 --- /dev/null +++ b/docs/QuoteApi.md @@ -0,0 +1,92 @@ +# \QuoteApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**QuoteGet**](QuoteApi.md#QuoteGet) | **Get** /quote | Get Quotes. +[**QuoteGetBucketed**](QuoteApi.md#QuoteGetBucketed) | **Get** /quote/bucketed | Get previous quotes in time buckets. + + +# **QuoteGet** +> []Quote QuoteGet(ctx, optional) +Get Quotes. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***QuoteGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a QuoteGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Quote**](Quote.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **QuoteGetBucketed** +> []Quote QuoteGetBucketed(ctx, optional) +Get previous quotes in time buckets. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***QuoteGetBucketedOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a QuoteGetBucketedOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **binSize** | **optional.String**| Time interval to bucket by. Available options: [1m,5m,1h,1d]. | [default to 1m] + **partial** | **optional.Bool**| If true, will send in-progress (incomplete) bins for the current time period. | [default to false] + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Quote**](Quote.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/SchemaApi.md b/docs/SchemaApi.md new file mode 100644 index 0000000..5bc744c --- /dev/null +++ b/docs/SchemaApi.md @@ -0,0 +1,65 @@ +# \SchemaApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**SchemaGet**](SchemaApi.md#SchemaGet) | **Get** /schema | Get model schemata for data objects returned by this API. +[**SchemaWebsocketHelp**](SchemaApi.md#SchemaWebsocketHelp) | **Get** /schema/websocketHelp | Returns help text & subject list for websocket usage. + + +# **SchemaGet** +> interface{} SchemaGet(ctx, optional) +Get model schemata for data objects returned by this API. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***SchemaGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a SchemaGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **model** | **optional.String**| Optional model filter. If omitted, will return all models. | + +### Return type + +[**interface{}**](interface{}.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **SchemaWebsocketHelp** +> interface{} SchemaWebsocketHelp(ctx, ) +Returns help text & subject list for websocket usage. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**interface{}**](interface{}.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Settlement.md b/docs/Settlement.md new file mode 100644 index 0000000..b5a1d6f --- /dev/null +++ b/docs/Settlement.md @@ -0,0 +1,18 @@ +# Settlement + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [default to null] +**SettlementType** | **string** | | [optional] [default to null] +**SettledPrice** | **float64** | | [optional] [default to null] +**OptionStrikePrice** | **float64** | | [optional] [default to null] +**OptionUnderlyingPrice** | **float64** | | [optional] [default to null] +**Bankrupt** | **float32** | | [optional] [default to null] +**TaxBase** | **float32** | | [optional] [default to null] +**TaxRate** | **float64** | | [optional] [default to null] + +[[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/docs/SettlementApi.md b/docs/SettlementApi.md new file mode 100644 index 0000000..0e2e7f4 --- /dev/null +++ b/docs/SettlementApi.md @@ -0,0 +1,49 @@ +# \SettlementApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**SettlementGet**](SettlementApi.md#SettlementGet) | **Get** /settlement | Get settlement history. + + +# **SettlementGet** +> []Settlement SettlementGet(ctx, optional) +Get settlement history. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***SettlementGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a SettlementGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Settlement**](Settlement.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/Stats.md b/docs/Stats.md new file mode 100644 index 0000000..b2ae066 --- /dev/null +++ b/docs/Stats.md @@ -0,0 +1,15 @@ +# Stats + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RootSymbol** | **string** | | [default to null] +**Currency** | **string** | | [optional] [default to null] +**Volume24h** | **float32** | | [optional] [default to null] +**Turnover24h** | **float32** | | [optional] [default to null] +**OpenInterest** | **float32** | | [optional] [default to null] +**OpenValue** | **float32** | | [optional] [default to null] + +[[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/docs/StatsApi.md b/docs/StatsApi.md new file mode 100644 index 0000000..b8a5208 --- /dev/null +++ b/docs/StatsApi.md @@ -0,0 +1,77 @@ +# \StatsApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**StatsGet**](StatsApi.md#StatsGet) | **Get** /stats | Get exchange-wide and per-series turnover and volume statistics. +[**StatsHistory**](StatsApi.md#StatsHistory) | **Get** /stats/history | Get historical exchange-wide and per-series turnover and volume statistics. +[**StatsHistoryUSD**](StatsApi.md#StatsHistoryUSD) | **Get** /stats/historyUSD | Get a summary of exchange statistics in USD. + + +# **StatsGet** +> []Stats StatsGet(ctx, ) +Get exchange-wide and per-series turnover and volume statistics. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]Stats**](Stats.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **StatsHistory** +> []StatsHistory StatsHistory(ctx, ) +Get historical exchange-wide and per-series turnover and volume statistics. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]StatsHistory**](StatsHistory.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **StatsHistoryUSD** +> []StatsUsd StatsHistoryUSD(ctx, ) +Get a summary of exchange statistics in USD. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]StatsUsd**](StatsUSD.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/StatsHistory.md b/docs/StatsHistory.md new file mode 100644 index 0000000..9964897 --- /dev/null +++ b/docs/StatsHistory.md @@ -0,0 +1,14 @@ +# StatsHistory + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Date** | [**time.Time**](time.Time.md) | | [default to null] +**RootSymbol** | **string** | | [default to null] +**Currency** | **string** | | [optional] [default to null] +**Volume** | **float32** | | [optional] [default to null] +**Turnover** | **float32** | | [optional] [default to null] + +[[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/docs/StatsUsd.md b/docs/StatsUsd.md new file mode 100644 index 0000000..f2ad6cd --- /dev/null +++ b/docs/StatsUsd.md @@ -0,0 +1,15 @@ +# StatsUsd + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RootSymbol** | **string** | | [default to null] +**Currency** | **string** | | [optional] [default to null] +**Turnover24h** | **float32** | | [optional] [default to null] +**Turnover30d** | **float32** | | [optional] [default to null] +**Turnover365d** | **float32** | | [optional] [default to null] +**Turnover** | **float32** | | [optional] [default to null] + +[[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/docs/Trade.md b/docs/Trade.md new file mode 100644 index 0000000..450c885 --- /dev/null +++ b/docs/Trade.md @@ -0,0 +1,19 @@ +# Trade + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [default to null] +**Side** | **string** | | [optional] [default to null] +**Size** | **float32** | | [optional] [default to null] +**Price** | **float64** | | [optional] [default to null] +**TickDirection** | **string** | | [optional] [default to null] +**TrdMatchID** | **string** | | [optional] [default to null] +**GrossValue** | **float32** | | [optional] [default to null] +**HomeNotional** | **float64** | | [optional] [default to null] +**ForeignNotional** | **float64** | | [optional] [default to null] + +[[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/docs/TradeApi.md b/docs/TradeApi.md new file mode 100644 index 0000000..c4ae099 --- /dev/null +++ b/docs/TradeApi.md @@ -0,0 +1,94 @@ +# \TradeApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TradeGet**](TradeApi.md#TradeGet) | **Get** /trade | Get Trades. +[**TradeGetBucketed**](TradeApi.md#TradeGetBucketed) | **Get** /trade/bucketed | Get previous trades in time buckets. + + +# **TradeGet** +> []Trade TradeGet(ctx, optional) +Get Trades. + +Please note that indices (symbols starting with `.`) post trades at intervals to the trade feed. These have a `size` of 0 and are used only to indicate a changing price. See [the FIX Spec](http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_AE_6569.html) for explanations of these fields. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***TradeGetOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a TradeGetOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]Trade**](Trade.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **TradeGetBucketed** +> []TradeBin TradeGetBucketed(ctx, optional) +Get previous trades in time buckets. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***TradeGetBucketedOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a TradeGetBucketedOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **binSize** | **optional.String**| Time interval to bucket by. Available options: [1m,5m,1h,1d]. | [default to 1m] + **partial** | **optional.Bool**| If true, will send in-progress (incomplete) bins for the current time period. | [default to false] + **symbol** | **optional.String**| Instrument symbol. Send a bare series (e.g. XBU) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. `XBU:monthly`. Timeframes are `daily`, `weekly`, `monthly`, `quarterly`, and `biquarterly`. | + **filter** | **optional.String**| Generic table filter. Send JSON key/value pairs, such as `{\"key\": \"value\"}`. You can key on individual fields, and do more advanced querying on timestamps. See the [Timestamp Docs](https://www.bitmex.com/app/restAPI#Timestamp-Filters) for more details. | + **columns** | **optional.String**| Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. | + **count** | **optional.Float32**| Number of results to fetch. | [default to 100] + **start** | **optional.Float32**| Starting point for results. | [default to 0] + **reverse** | **optional.Bool**| If true, will sort results newest first. | [default to false] + **startTime** | **optional.Time**| Starting date filter for results. | + **endTime** | **optional.Time**| Ending date filter for results. | + +### Return type + +[**[]TradeBin**](TradeBin.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/TradeBin.md b/docs/TradeBin.md new file mode 100644 index 0000000..339efab --- /dev/null +++ b/docs/TradeBin.md @@ -0,0 +1,22 @@ +# TradeBin + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Timestamp** | [**time.Time**](time.Time.md) | | [default to null] +**Symbol** | **string** | | [default to null] +**Open** | **float64** | | [optional] [default to null] +**High** | **float64** | | [optional] [default to null] +**Low** | **float64** | | [optional] [default to null] +**Close** | **float64** | | [optional] [default to null] +**Trades** | **float32** | | [optional] [default to null] +**Volume** | **float32** | | [optional] [default to null] +**Vwap** | **float64** | | [optional] [default to null] +**LastSize** | **float32** | | [optional] [default to null] +**Turnover** | **float32** | | [optional] [default to null] +**HomeNotional** | **float64** | | [optional] [default to null] +**ForeignNotional** | **float64** | | [optional] [default to null] + +[[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/docs/Transaction.md b/docs/Transaction.md new file mode 100644 index 0000000..583d64d --- /dev/null +++ b/docs/Transaction.md @@ -0,0 +1,21 @@ +# Transaction + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TransactID** | **string** | | [default to null] +**Account** | **float32** | | [optional] [default to null] +**Currency** | **string** | | [optional] [default to null] +**TransactType** | **string** | | [optional] [default to null] +**Amount** | **float32** | | [optional] [default to null] +**Fee** | **float32** | | [optional] [default to null] +**TransactStatus** | **string** | | [optional] [default to null] +**Address** | **string** | | [optional] [default to null] +**Tx** | **string** | | [optional] [default to null] +**Text** | **string** | | [optional] [default to null] +**TransactTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] + +[[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/docs/User.md b/docs/User.md new file mode 100644 index 0000000..023b6fe --- /dev/null +++ b/docs/User.md @@ -0,0 +1,26 @@ +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **float32** | | [optional] [default to null] +**OwnerId** | **float32** | | [optional] [default to null] +**Firstname** | **string** | | [optional] [default to null] +**Lastname** | **string** | | [optional] [default to null] +**Username** | **string** | | [default to null] +**Email** | **string** | | [default to null] +**Phone** | **string** | | [optional] [default to null] +**Created** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**LastUpdated** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Preferences** | [***UserPreferences**](UserPreferences.md) | | [optional] [default to null] +**TFAEnabled** | **string** | | [optional] [default to null] +**AffiliateID** | **string** | | [optional] [default to null] +**PgpPubKey** | **string** | | [optional] [default to null] +**Country** | **string** | | [optional] [default to null] +**GeoipCountry** | **string** | | [optional] [default to null] +**GeoipRegion** | **string** | | [optional] [default to null] +**Typ** | **string** | | [optional] [default to null] + +[[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/docs/UserApi.md b/docs/UserApi.md new file mode 100644 index 0000000..d120bc5 --- /dev/null +++ b/docs/UserApi.md @@ -0,0 +1,674 @@ +# \UserApi + +All URIs are relative to *https://localhost/api/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**UserCancelWithdrawal**](UserApi.md#UserCancelWithdrawal) | **Post** /user/cancelWithdrawal | Cancel a withdrawal. +[**UserCheckReferralCode**](UserApi.md#UserCheckReferralCode) | **Get** /user/checkReferralCode | Check if a referral code is valid. +[**UserConfirm**](UserApi.md#UserConfirm) | **Post** /user/confirmEmail | Confirm your email address with a token. +[**UserConfirmEnableTFA**](UserApi.md#UserConfirmEnableTFA) | **Post** /user/confirmEnableTFA | Confirm two-factor auth for this account. If using a Yubikey, simply send a token to this endpoint. +[**UserConfirmWithdrawal**](UserApi.md#UserConfirmWithdrawal) | **Post** /user/confirmWithdrawal | Confirm a withdrawal. +[**UserDisableTFA**](UserApi.md#UserDisableTFA) | **Post** /user/disableTFA | Disable two-factor auth for this account. +[**UserGet**](UserApi.md#UserGet) | **Get** /user | Get your user model. +[**UserGetAffiliateStatus**](UserApi.md#UserGetAffiliateStatus) | **Get** /user/affiliateStatus | Get your current affiliate/referral status. +[**UserGetCommission**](UserApi.md#UserGetCommission) | **Get** /user/commission | Get your account's commission status. +[**UserGetDepositAddress**](UserApi.md#UserGetDepositAddress) | **Get** /user/depositAddress | Get a deposit address. +[**UserGetMargin**](UserApi.md#UserGetMargin) | **Get** /user/margin | Get your account's margin status. Send a currency of \"all\" to receive an array of all supported currencies. +[**UserGetWallet**](UserApi.md#UserGetWallet) | **Get** /user/wallet | Get your current wallet information. +[**UserGetWalletHistory**](UserApi.md#UserGetWalletHistory) | **Get** /user/walletHistory | Get a history of all of your wallet transactions (deposits, withdrawals, PNL). +[**UserGetWalletSummary**](UserApi.md#UserGetWalletSummary) | **Get** /user/walletSummary | Get a summary of all of your wallet transactions (deposits, withdrawals, PNL). +[**UserLogout**](UserApi.md#UserLogout) | **Post** /user/logout | Log out of BitMEX. +[**UserLogoutAll**](UserApi.md#UserLogoutAll) | **Post** /user/logoutAll | Log all systems out of BitMEX. This will revoke all of your account's access tokens, logging you out on all devices. +[**UserMinWithdrawalFee**](UserApi.md#UserMinWithdrawalFee) | **Get** /user/minWithdrawalFee | Get the minimum withdrawal fee for a currency. +[**UserRequestEnableTFA**](UserApi.md#UserRequestEnableTFA) | **Post** /user/requestEnableTFA | Get secret key for setting up two-factor auth. +[**UserRequestWithdrawal**](UserApi.md#UserRequestWithdrawal) | **Post** /user/requestWithdrawal | Request a withdrawal to an external wallet. +[**UserSavePreferences**](UserApi.md#UserSavePreferences) | **Post** /user/preferences | Save user preferences. +[**UserUpdate**](UserApi.md#UserUpdate) | **Put** /user | Update your password, name, and other attributes. + + +# **UserCancelWithdrawal** +> Transaction UserCancelWithdrawal(ctx, token) +Cancel a withdrawal. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **token** | **string**| | + +### Return type + +[**Transaction**](Transaction.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserCheckReferralCode** +> float64 UserCheckReferralCode(ctx, optional) +Check if a referral code is valid. + +If the code is valid, responds with the referral code's discount (e.g. `0.1` for 10%). Otherwise, will return a 404. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserCheckReferralCodeOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserCheckReferralCodeOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **referralCode** | **optional.String**| | + +### Return type + +**float64** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserConfirm** +> AccessToken UserConfirm(ctx, token) +Confirm your email address with a token. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **token** | **string**| | + +### Return type + +[**AccessToken**](AccessToken.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserConfirmEnableTFA** +> bool UserConfirmEnableTFA(ctx, token, optional) +Confirm two-factor auth for this account. If using a Yubikey, simply send a token to this endpoint. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **token** | **string**| Token from your selected TFA type. | + **optional** | ***UserConfirmEnableTFAOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserConfirmEnableTFAOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **type_** | **optional.String**| Two-factor auth type. Supported types: 'GA' (Google Authenticator), 'Yubikey' | + +### Return type + +**bool** + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserConfirmWithdrawal** +> Transaction UserConfirmWithdrawal(ctx, token) +Confirm a withdrawal. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **token** | **string**| | + +### Return type + +[**Transaction**](Transaction.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserDisableTFA** +> bool UserDisableTFA(ctx, token, optional) +Disable two-factor auth for this account. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **token** | **string**| Token from your selected TFA type. | + **optional** | ***UserDisableTFAOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserDisableTFAOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **type_** | **optional.String**| Two-factor auth type. Supported types: 'GA' (Google Authenticator) | + +### Return type + +**bool** + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGet** +> User UserGet(ctx, ) +Get your user model. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**User**](User.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetAffiliateStatus** +> Affiliate UserGetAffiliateStatus(ctx, ) +Get your current affiliate/referral status. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**Affiliate**](Affiliate.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetCommission** +> []UserCommission UserGetCommission(ctx, ) +Get your account's commission status. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +[**[]UserCommission**](UserCommission.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetDepositAddress** +> string UserGetDepositAddress(ctx, optional) +Get a deposit address. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserGetDepositAddressOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserGetDepositAddressOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +**string** + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetMargin** +> Margin UserGetMargin(ctx, optional) +Get your account's margin status. Send a currency of \"all\" to receive an array of all supported currencies. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserGetMarginOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserGetMarginOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +[**Margin**](Margin.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetWallet** +> Wallet UserGetWallet(ctx, optional) +Get your current wallet information. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserGetWalletOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserGetWalletOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +[**Wallet**](Wallet.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetWalletHistory** +> []Transaction UserGetWalletHistory(ctx, optional) +Get a history of all of your wallet transactions (deposits, withdrawals, PNL). + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserGetWalletHistoryOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserGetWalletHistoryOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +[**[]Transaction**](Transaction.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserGetWalletSummary** +> []Transaction UserGetWalletSummary(ctx, optional) +Get a summary of all of your wallet transactions (deposits, withdrawals, PNL). + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserGetWalletSummaryOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserGetWalletSummaryOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +[**[]Transaction**](Transaction.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserLogout** +> UserLogout(ctx, ) +Log out of BitMEX. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserLogoutAll** +> float64 UserLogoutAll(ctx, ) +Log all systems out of BitMEX. This will revoke all of your account's access tokens, logging you out on all devices. + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +**float64** + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserMinWithdrawalFee** +> interface{} UserMinWithdrawalFee(ctx, optional) +Get the minimum withdrawal fee for a currency. + +This is changed based on network conditions to ensure timely withdrawals. During network congestion, this may be high. The fee is returned in the same currency. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserMinWithdrawalFeeOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserMinWithdrawalFeeOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **currency** | **optional.String**| | [default to XBt] + +### Return type + +[**interface{}**](interface{}.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserRequestEnableTFA** +> bool UserRequestEnableTFA(ctx, optional) +Get secret key for setting up two-factor auth. + +Use /confirmEnableTFA directly for Yubikeys. This fails if TFA is already enabled. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserRequestEnableTFAOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserRequestEnableTFAOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **type_** | **optional.String**| Two-factor auth type. Supported types: 'GA' (Google Authenticator) | + +### Return type + +**bool** + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserRequestWithdrawal** +> Transaction UserRequestWithdrawal(ctx, currency, amount, address, optional) +Request a withdrawal to an external wallet. + +This will send a confirmation email to the email address on record, unless requested via an API Key with the `withdraw` permission. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **currency** | **string**| Currency you're withdrawing. Options: `XBt` | [default to XBt] + **amount** | **float32**| Amount of withdrawal currency. | + **address** | **string**| Destination Address. | + **optional** | ***UserRequestWithdrawalOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserRequestWithdrawalOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + + + **otpToken** | **optional.String**| 2FA token. Required if 2FA is enabled on your account. | + **fee** | **optional.Float64**| Network fee for Bitcoin withdrawals. If not specified, a default value will be calculated based on Bitcoin network conditions. You will have a chance to confirm this via email. | + +### Return type + +[**Transaction**](Transaction.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserSavePreferences** +> User UserSavePreferences(ctx, prefs, optional) +Save user preferences. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **prefs** | **string**| | + **optional** | ***UserSavePreferencesOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserSavePreferencesOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **overwrite** | **optional.Bool**| If true, will overwrite all existing preferences. | [default to false] + +### Return type + +[**User**](User.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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) + +# **UserUpdate** +> User UserUpdate(ctx, optional) +Update your password, name, and other attributes. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***UserUpdateOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a UserUpdateOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **firstname** | **optional.String**| | + **lastname** | **optional.String**| | + **oldPassword** | **optional.String**| | + **newPassword** | **optional.String**| | + **newPasswordConfirm** | **optional.String**| | + **username** | **optional.String**| Username can only be set once. To reset, email support. | + **country** | **optional.String**| Country of residence. | + **pgpPubKey** | **optional.String**| PGP Public Key. If specified, automated emails will be sentwith this key. | + +### Return type + +[**User**](User.md) + +### Authorization + +[apiKey](../README.md#apiKey), [apiNonce](../README.md#apiNonce), [apiSignature](../README.md#apiSignature) + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded + - **Accept**: application/json, application/xml, text/xml, application/javascript, text/javascript + +[[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/docs/UserCommission.md b/docs/UserCommission.md new file mode 100644 index 0000000..4a9cc54 --- /dev/null +++ b/docs/UserCommission.md @@ -0,0 +1,13 @@ +# UserCommission + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MakerFee** | **float64** | | [optional] [default to null] +**TakerFee** | **float64** | | [optional] [default to null] +**SettlementFee** | **float64** | | [optional] [default to null] +**MaxFee** | **float64** | | [optional] [default to null] + +[[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/docs/UserPreferences.md b/docs/UserPreferences.md new file mode 100644 index 0000000..efa838a --- /dev/null +++ b/docs/UserPreferences.md @@ -0,0 +1,35 @@ +# UserPreferences + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AlertOnLiquidations** | **bool** | | [optional] [default to null] +**AnimationsEnabled** | **bool** | | [optional] [default to null] +**AnnouncementsLastSeen** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**ChatChannelID** | **float64** | | [optional] [default to null] +**ColorTheme** | **string** | | [optional] [default to null] +**Currency** | **string** | | [optional] [default to null] +**Debug** | **bool** | | [optional] [default to null] +**DisableEmails** | **[]string** | | [optional] [default to null] +**HideConfirmDialogs** | **[]string** | | [optional] [default to null] +**HideConnectionModal** | **bool** | | [optional] [default to null] +**HideFromLeaderboard** | **bool** | | [optional] [default to null] +**HideNameFromLeaderboard** | **bool** | | [optional] [default to null] +**HideNotifications** | **[]string** | | [optional] [default to null] +**Locale** | **string** | | [optional] [default to null] +**MsgsSeen** | **[]string** | | [optional] [default to null] +**OrderBookBinning** | [***interface{}**](interface{}.md) | | [optional] [default to null] +**OrderBookType** | **string** | | [optional] [default to null] +**OrderClearImmediate** | **bool** | | [optional] [default to null] +**OrderControlsPlusMinus** | **bool** | | [optional] [default to null] +**ShowLocaleNumbers** | **bool** | | [optional] [default to null] +**Sounds** | **[]string** | | [optional] [default to null] +**StrictIPCheck** | **bool** | | [optional] [default to null] +**StrictTimeout** | **bool** | | [optional] [default to null] +**TickerGroup** | **string** | | [optional] [default to null] +**TickerPinned** | **bool** | | [optional] [default to null] +**TradeLayout** | **string** | | [optional] [default to null] + +[[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/docs/Wallet.md b/docs/Wallet.md new file mode 100644 index 0000000..6d82416 --- /dev/null +++ b/docs/Wallet.md @@ -0,0 +1,34 @@ +# Wallet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Account** | **float32** | | [default to null] +**Currency** | **string** | | [default to null] +**PrevDeposited** | **float32** | | [optional] [default to null] +**PrevWithdrawn** | **float32** | | [optional] [default to null] +**PrevTransferIn** | **float32** | | [optional] [default to null] +**PrevTransferOut** | **float32** | | [optional] [default to null] +**PrevAmount** | **float32** | | [optional] [default to null] +**PrevTimestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**DeltaDeposited** | **float32** | | [optional] [default to null] +**DeltaWithdrawn** | **float32** | | [optional] [default to null] +**DeltaTransferIn** | **float32** | | [optional] [default to null] +**DeltaTransferOut** | **float32** | | [optional] [default to null] +**DeltaAmount** | **float32** | | [optional] [default to null] +**Deposited** | **float32** | | [optional] [default to null] +**Withdrawn** | **float32** | | [optional] [default to null] +**TransferIn** | **float32** | | [optional] [default to null] +**TransferOut** | **float32** | | [optional] [default to null] +**Amount** | **float32** | | [optional] [default to null] +**PendingCredit** | **float32** | | [optional] [default to null] +**PendingDebit** | **float32** | | [optional] [default to null] +**ConfirmedDebit** | **float32** | | [optional] [default to null] +**Timestamp** | [**time.Time**](time.Time.md) | | [optional] [default to null] +**Addr** | **string** | | [optional] [default to null] +**Script** | **string** | | [optional] [default to null] +**WithdrawalLock** | **[]string** | | [optional] [default to null] + +[[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/docs/XAny.md b/docs/XAny.md new file mode 100644 index 0000000..d3e7a3e --- /dev/null +++ b/docs/XAny.md @@ -0,0 +1,9 @@ +# XAny + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/git_push.sh b/git_push.sh new file mode 100644 index 0000000..ae01b18 --- /dev/null +++ b/git_push.sh @@ -0,0 +1,52 @@ +#!/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 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +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://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${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://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/model_access_token.go b/model_access_token.go new file mode 100644 index 0000000..5298818 --- /dev/null +++ b/model_access_token.go @@ -0,0 +1,23 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type AccessToken struct { + Id string `json:"id"` + // time to live in seconds (2 weeks by default) + Ttl float64 `json:"ttl,omitempty"` + Created time.Time `json:"created,omitempty"` + UserId float64 `json:"userId,omitempty"` +} diff --git a/model_affiliate.go b/model_affiliate.go new file mode 100644 index 0000000..991662c --- /dev/null +++ b/model_affiliate.go @@ -0,0 +1,33 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type Affiliate struct { + Account float32 `json:"account"` + Currency string `json:"currency"` + PrevPayout float32 `json:"prevPayout,omitempty"` + PrevTurnover float32 `json:"prevTurnover,omitempty"` + PrevComm float32 `json:"prevComm,omitempty"` + PrevTimestamp time.Time `json:"prevTimestamp,omitempty"` + ExecTurnover float32 `json:"execTurnover,omitempty"` + ExecComm float32 `json:"execComm,omitempty"` + TotalReferrals float32 `json:"totalReferrals,omitempty"` + TotalTurnover float32 `json:"totalTurnover,omitempty"` + TotalComm float32 `json:"totalComm,omitempty"` + PayoutPcnt float64 `json:"payoutPcnt,omitempty"` + PendingPayout float32 `json:"pendingPayout,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` + ReferrerAccount float64 `json:"referrerAccount,omitempty"` +} diff --git a/model_announcement.go b/model_announcement.go new file mode 100644 index 0000000..bff0c80 --- /dev/null +++ b/model_announcement.go @@ -0,0 +1,24 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Public Announcements +type Announcement struct { + Id float32 `json:"id"` + Link string `json:"link,omitempty"` + Title string `json:"title,omitempty"` + Content string `json:"content,omitempty"` + Date time.Time `json:"date,omitempty"` +} diff --git a/model_api_key.go b/model_api_key.go new file mode 100644 index 0000000..bdbcea6 --- /dev/null +++ b/model_api_key.go @@ -0,0 +1,28 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Persistent API Keys for Developers +type ApiKey struct { + Id string `json:"id"` + Secret string `json:"secret"` + Name string `json:"name"` + Nonce float32 `json:"nonce"` + Cidr string `json:"cidr,omitempty"` + Permissions []XAny `json:"permissions,omitempty"` + Enabled bool `json:"enabled,omitempty"` + UserId float32 `json:"userId"` + Created time.Time `json:"created,omitempty"` +} diff --git a/model_chat.go b/model_chat.go new file mode 100644 index 0000000..b016fd9 --- /dev/null +++ b/model_chat.go @@ -0,0 +1,26 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Trollbox Data +type Chat struct { + Id float32 `json:"id,omitempty"` + Date time.Time `json:"date"` + User string `json:"user"` + Message string `json:"message"` + Html string `json:"html"` + FromBot bool `json:"fromBot,omitempty"` + ChannelID float64 `json:"channelID,omitempty"` +} diff --git a/model_chat_channel.go b/model_chat_channel.go new file mode 100644 index 0000000..57a2a6a --- /dev/null +++ b/model_chat_channel.go @@ -0,0 +1,16 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type ChatChannel struct { + Id float32 `json:"id,omitempty"` + Name string `json:"name"` +} diff --git a/model_connected_users.go b/model_connected_users.go new file mode 100644 index 0000000..255ce97 --- /dev/null +++ b/model_connected_users.go @@ -0,0 +1,16 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type ConnectedUsers struct { + Users float32 `json:"users,omitempty"` + Bots float32 `json:"bots,omitempty"` +} diff --git a/model_error.go b/model_error.go new file mode 100644 index 0000000..0317f44 --- /dev/null +++ b/model_error.go @@ -0,0 +1,15 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type ModelError struct { + Error_ *ErrorError `json:"error"` +} diff --git a/model_error_error.go b/model_error_error.go new file mode 100644 index 0000000..6194bfa --- /dev/null +++ b/model_error_error.go @@ -0,0 +1,16 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type ErrorError struct { + Message string `json:"message,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/model_execution.go b/model_execution.go new file mode 100644 index 0000000..9c5f243 --- /dev/null +++ b/model_execution.go @@ -0,0 +1,66 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Raw Order and Balance Data +type Execution struct { + ExecID string `json:"execID"` + OrderID string `json:"orderID,omitempty"` + ClOrdID string `json:"clOrdID,omitempty"` + ClOrdLinkID string `json:"clOrdLinkID,omitempty"` + Account float32 `json:"account,omitempty"` + Symbol string `json:"symbol,omitempty"` + Side string `json:"side,omitempty"` + LastQty float32 `json:"lastQty,omitempty"` + LastPx float64 `json:"lastPx,omitempty"` + UnderlyingLastPx float64 `json:"underlyingLastPx,omitempty"` + LastMkt string `json:"lastMkt,omitempty"` + LastLiquidityInd string `json:"lastLiquidityInd,omitempty"` + SimpleOrderQty float64 `json:"simpleOrderQty,omitempty"` + OrderQty float32 `json:"orderQty,omitempty"` + Price float64 `json:"price,omitempty"` + DisplayQty float32 `json:"displayQty,omitempty"` + StopPx float64 `json:"stopPx,omitempty"` + PegOffsetValue float64 `json:"pegOffsetValue,omitempty"` + PegPriceType string `json:"pegPriceType,omitempty"` + Currency string `json:"currency,omitempty"` + SettlCurrency string `json:"settlCurrency,omitempty"` + ExecType string `json:"execType,omitempty"` + OrdType string `json:"ordType,omitempty"` + TimeInForce string `json:"timeInForce,omitempty"` + ExecInst string `json:"execInst,omitempty"` + ContingencyType string `json:"contingencyType,omitempty"` + ExDestination string `json:"exDestination,omitempty"` + OrdStatus string `json:"ordStatus,omitempty"` + Triggered string `json:"triggered,omitempty"` + WorkingIndicator bool `json:"workingIndicator,omitempty"` + OrdRejReason string `json:"ordRejReason,omitempty"` + SimpleLeavesQty float64 `json:"simpleLeavesQty,omitempty"` + LeavesQty float32 `json:"leavesQty,omitempty"` + SimpleCumQty float64 `json:"simpleCumQty,omitempty"` + CumQty float32 `json:"cumQty,omitempty"` + AvgPx float64 `json:"avgPx,omitempty"` + Commission float64 `json:"commission,omitempty"` + TradePublishIndicator string `json:"tradePublishIndicator,omitempty"` + MultiLegReportingType string `json:"multiLegReportingType,omitempty"` + Text string `json:"text,omitempty"` + TrdMatchID string `json:"trdMatchID,omitempty"` + ExecCost float32 `json:"execCost,omitempty"` + ExecComm float32 `json:"execComm,omitempty"` + HomeNotional float64 `json:"homeNotional,omitempty"` + ForeignNotional float64 `json:"foreignNotional,omitempty"` + TransactTime time.Time `json:"transactTime,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` +} diff --git a/model_funding.go b/model_funding.go new file mode 100644 index 0000000..045328d --- /dev/null +++ b/model_funding.go @@ -0,0 +1,24 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Swap Funding History +type Funding struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol"` + FundingInterval time.Time `json:"fundingInterval,omitempty"` + FundingRate float64 `json:"fundingRate,omitempty"` + FundingRateDaily float64 `json:"fundingRateDaily,omitempty"` +} diff --git a/model_index_composite.go b/model_index_composite.go new file mode 100644 index 0000000..56234c0 --- /dev/null +++ b/model_index_composite.go @@ -0,0 +1,25 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type IndexComposite struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol,omitempty"` + IndexSymbol string `json:"indexSymbol,omitempty"` + Reference string `json:"reference,omitempty"` + LastPrice float64 `json:"lastPrice,omitempty"` + Weight float64 `json:"weight,omitempty"` + Logged time.Time `json:"logged,omitempty"` +} diff --git a/model_inline_response_200.go b/model_inline_response_200.go new file mode 100644 index 0000000..a7daaae --- /dev/null +++ b/model_inline_response_200.go @@ -0,0 +1,15 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type InlineResponse200 struct { + Success bool `json:"success,omitempty"` +} diff --git a/model_inline_response_200_1.go b/model_inline_response_200_1.go new file mode 100644 index 0000000..c1cd9ac --- /dev/null +++ b/model_inline_response_200_1.go @@ -0,0 +1,15 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type InlineResponse2001 struct { + Name string `json:"name,omitempty"` +} diff --git a/model_instrument.go b/model_instrument.go new file mode 100644 index 0000000..9155799 --- /dev/null +++ b/model_instrument.go @@ -0,0 +1,120 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Tradeable Contracts, Indices, and History +type Instrument struct { + Symbol string `json:"symbol"` + RootSymbol string `json:"rootSymbol,omitempty"` + State string `json:"state,omitempty"` + Typ string `json:"typ,omitempty"` + Listing time.Time `json:"listing,omitempty"` + Front time.Time `json:"front,omitempty"` + Expiry time.Time `json:"expiry,omitempty"` + Settle time.Time `json:"settle,omitempty"` + RelistInterval time.Time `json:"relistInterval,omitempty"` + InverseLeg string `json:"inverseLeg,omitempty"` + SellLeg string `json:"sellLeg,omitempty"` + BuyLeg string `json:"buyLeg,omitempty"` + OptionStrikePcnt float64 `json:"optionStrikePcnt,omitempty"` + OptionStrikeRound float64 `json:"optionStrikeRound,omitempty"` + OptionStrikePrice float64 `json:"optionStrikePrice,omitempty"` + OptionMultiplier float64 `json:"optionMultiplier,omitempty"` + PositionCurrency string `json:"positionCurrency,omitempty"` + Underlying string `json:"underlying,omitempty"` + QuoteCurrency string `json:"quoteCurrency,omitempty"` + UnderlyingSymbol string `json:"underlyingSymbol,omitempty"` + Reference string `json:"reference,omitempty"` + ReferenceSymbol string `json:"referenceSymbol,omitempty"` + CalcInterval time.Time `json:"calcInterval,omitempty"` + PublishInterval time.Time `json:"publishInterval,omitempty"` + PublishTime time.Time `json:"publishTime,omitempty"` + MaxOrderQty float32 `json:"maxOrderQty,omitempty"` + MaxPrice float64 `json:"maxPrice,omitempty"` + LotSize float32 `json:"lotSize,omitempty"` + TickSize float64 `json:"tickSize,omitempty"` + Multiplier float32 `json:"multiplier,omitempty"` + SettlCurrency string `json:"settlCurrency,omitempty"` + UnderlyingToPositionMultiplier float32 `json:"underlyingToPositionMultiplier,omitempty"` + UnderlyingToSettleMultiplier float32 `json:"underlyingToSettleMultiplier,omitempty"` + QuoteToSettleMultiplier float32 `json:"quoteToSettleMultiplier,omitempty"` + IsQuanto bool `json:"isQuanto,omitempty"` + IsInverse bool `json:"isInverse,omitempty"` + InitMargin float64 `json:"initMargin,omitempty"` + MaintMargin float64 `json:"maintMargin,omitempty"` + RiskLimit float32 `json:"riskLimit,omitempty"` + RiskStep float32 `json:"riskStep,omitempty"` + Limit float64 `json:"limit,omitempty"` + Capped bool `json:"capped,omitempty"` + Taxed bool `json:"taxed,omitempty"` + Deleverage bool `json:"deleverage,omitempty"` + MakerFee float64 `json:"makerFee,omitempty"` + TakerFee float64 `json:"takerFee,omitempty"` + SettlementFee float64 `json:"settlementFee,omitempty"` + InsuranceFee float64 `json:"insuranceFee,omitempty"` + FundingBaseSymbol string `json:"fundingBaseSymbol,omitempty"` + FundingQuoteSymbol string `json:"fundingQuoteSymbol,omitempty"` + FundingPremiumSymbol string `json:"fundingPremiumSymbol,omitempty"` + FundingTimestamp time.Time `json:"fundingTimestamp,omitempty"` + FundingInterval time.Time `json:"fundingInterval,omitempty"` + FundingRate float64 `json:"fundingRate,omitempty"` + IndicativeFundingRate float64 `json:"indicativeFundingRate,omitempty"` + RebalanceTimestamp time.Time `json:"rebalanceTimestamp,omitempty"` + RebalanceInterval time.Time `json:"rebalanceInterval,omitempty"` + OpeningTimestamp time.Time `json:"openingTimestamp,omitempty"` + ClosingTimestamp time.Time `json:"closingTimestamp,omitempty"` + SessionInterval time.Time `json:"sessionInterval,omitempty"` + PrevClosePrice float64 `json:"prevClosePrice,omitempty"` + LimitDownPrice float64 `json:"limitDownPrice,omitempty"` + LimitUpPrice float64 `json:"limitUpPrice,omitempty"` + BankruptLimitDownPrice float64 `json:"bankruptLimitDownPrice,omitempty"` + BankruptLimitUpPrice float64 `json:"bankruptLimitUpPrice,omitempty"` + PrevTotalVolume float32 `json:"prevTotalVolume,omitempty"` + TotalVolume float32 `json:"totalVolume,omitempty"` + Volume float32 `json:"volume,omitempty"` + Volume24h float32 `json:"volume24h,omitempty"` + PrevTotalTurnover float32 `json:"prevTotalTurnover,omitempty"` + TotalTurnover float32 `json:"totalTurnover,omitempty"` + Turnover float32 `json:"turnover,omitempty"` + Turnover24h float32 `json:"turnover24h,omitempty"` + PrevPrice24h float64 `json:"prevPrice24h,omitempty"` + Vwap float64 `json:"vwap,omitempty"` + HighPrice float64 `json:"highPrice,omitempty"` + LowPrice float64 `json:"lowPrice,omitempty"` + LastPrice float64 `json:"lastPrice,omitempty"` + LastPriceProtected float64 `json:"lastPriceProtected,omitempty"` + LastTickDirection string `json:"lastTickDirection,omitempty"` + LastChangePcnt float64 `json:"lastChangePcnt,omitempty"` + BidPrice float64 `json:"bidPrice,omitempty"` + MidPrice float64 `json:"midPrice,omitempty"` + AskPrice float64 `json:"askPrice,omitempty"` + ImpactBidPrice float64 `json:"impactBidPrice,omitempty"` + ImpactMidPrice float64 `json:"impactMidPrice,omitempty"` + ImpactAskPrice float64 `json:"impactAskPrice,omitempty"` + HasLiquidity bool `json:"hasLiquidity,omitempty"` + OpenInterest float32 `json:"openInterest,omitempty"` + OpenValue float32 `json:"openValue,omitempty"` + FairMethod string `json:"fairMethod,omitempty"` + FairBasisRate float64 `json:"fairBasisRate,omitempty"` + FairBasis float64 `json:"fairBasis,omitempty"` + FairPrice float64 `json:"fairPrice,omitempty"` + MarkMethod string `json:"markMethod,omitempty"` + MarkPrice float64 `json:"markPrice,omitempty"` + IndicativeTaxRate float64 `json:"indicativeTaxRate,omitempty"` + IndicativeSettlePrice float64 `json:"indicativeSettlePrice,omitempty"` + OptionUnderlyingPrice float64 `json:"optionUnderlyingPrice,omitempty"` + SettledPrice float64 `json:"settledPrice,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` +} diff --git a/model_instrument_interval.go b/model_instrument_interval.go new file mode 100644 index 0000000..05d220d --- /dev/null +++ b/model_instrument_interval.go @@ -0,0 +1,16 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type InstrumentInterval struct { + Intervals []string `json:"intervals"` + Symbols []string `json:"symbols"` +} diff --git a/model_insurance.go b/model_insurance.go new file mode 100644 index 0000000..8b255e2 --- /dev/null +++ b/model_insurance.go @@ -0,0 +1,22 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Insurance Fund Data +type Insurance struct { + Currency string `json:"currency"` + Timestamp time.Time `json:"timestamp"` + WalletBalance float32 `json:"walletBalance,omitempty"` +} diff --git a/model_leaderboard.go b/model_leaderboard.go new file mode 100644 index 0000000..e4db777 --- /dev/null +++ b/model_leaderboard.go @@ -0,0 +1,18 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +// Information on Top Users +type Leaderboard struct { + Name string `json:"name"` + IsRealName bool `json:"isRealName,omitempty"` + Profit float64 `json:"profit,omitempty"` +} diff --git a/model_liquidation.go b/model_liquidation.go new file mode 100644 index 0000000..4b7e12e --- /dev/null +++ b/model_liquidation.go @@ -0,0 +1,20 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +// Active Liquidations +type Liquidation struct { + OrderID string `json:"orderID"` + Symbol string `json:"symbol,omitempty"` + Side string `json:"side,omitempty"` + Price float64 `json:"price,omitempty"` + LeavesQty float32 `json:"leavesQty,omitempty"` +} diff --git a/model_margin.go b/model_margin.go new file mode 100644 index 0000000..3561acf --- /dev/null +++ b/model_margin.go @@ -0,0 +1,59 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type Margin struct { + Account float32 `json:"account"` + Currency string `json:"currency"` + RiskLimit float32 `json:"riskLimit,omitempty"` + PrevState string `json:"prevState,omitempty"` + State string `json:"state,omitempty"` + Action string `json:"action,omitempty"` + Amount float32 `json:"amount,omitempty"` + PendingCredit float32 `json:"pendingCredit,omitempty"` + PendingDebit float32 `json:"pendingDebit,omitempty"` + ConfirmedDebit float32 `json:"confirmedDebit,omitempty"` + PrevRealisedPnl float32 `json:"prevRealisedPnl,omitempty"` + PrevUnrealisedPnl float32 `json:"prevUnrealisedPnl,omitempty"` + GrossComm float32 `json:"grossComm,omitempty"` + GrossOpenCost float32 `json:"grossOpenCost,omitempty"` + GrossOpenPremium float32 `json:"grossOpenPremium,omitempty"` + GrossExecCost float32 `json:"grossExecCost,omitempty"` + GrossMarkValue float32 `json:"grossMarkValue,omitempty"` + RiskValue float32 `json:"riskValue,omitempty"` + TaxableMargin float32 `json:"taxableMargin,omitempty"` + InitMargin float32 `json:"initMargin,omitempty"` + MaintMargin float32 `json:"maintMargin,omitempty"` + SessionMargin float32 `json:"sessionMargin,omitempty"` + TargetExcessMargin float32 `json:"targetExcessMargin,omitempty"` + VarMargin float32 `json:"varMargin,omitempty"` + RealisedPnl float32 `json:"realisedPnl,omitempty"` + UnrealisedPnl float32 `json:"unrealisedPnl,omitempty"` + IndicativeTax float32 `json:"indicativeTax,omitempty"` + UnrealisedProfit float32 `json:"unrealisedProfit,omitempty"` + SyntheticMargin float32 `json:"syntheticMargin,omitempty"` + WalletBalance float32 `json:"walletBalance,omitempty"` + MarginBalance float32 `json:"marginBalance,omitempty"` + MarginBalancePcnt float64 `json:"marginBalancePcnt,omitempty"` + MarginLeverage float64 `json:"marginLeverage,omitempty"` + MarginUsedPcnt float64 `json:"marginUsedPcnt,omitempty"` + ExcessMargin float32 `json:"excessMargin,omitempty"` + ExcessMarginPcnt float64 `json:"excessMarginPcnt,omitempty"` + AvailableMargin float32 `json:"availableMargin,omitempty"` + WithdrawableMargin float32 `json:"withdrawableMargin,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` + GrossLastValue float32 `json:"grossLastValue,omitempty"` + Commission float64 `json:"commission,omitempty"` +} diff --git a/model_notification.go b/model_notification.go new file mode 100644 index 0000000..e2df3f4 --- /dev/null +++ b/model_notification.go @@ -0,0 +1,29 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Account Notifications +type Notification struct { + Id float32 `json:"id,omitempty"` + Date time.Time `json:"date"` + Title string `json:"title"` + Body string `json:"body"` + Ttl float32 `json:"ttl"` + Type_ string `json:"type,omitempty"` + Closable bool `json:"closable,omitempty"` + Persist bool `json:"persist,omitempty"` + WaitForVisibility bool `json:"waitForVisibility,omitempty"` + Sound string `json:"sound,omitempty"` +} diff --git a/model_order.go b/model_order.go new file mode 100644 index 0000000..b09504c --- /dev/null +++ b/model_order.go @@ -0,0 +1,52 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Placement, Cancellation, Amending, and History +type Order struct { + OrderID string `json:"orderID"` + ClOrdID string `json:"clOrdID,omitempty"` + ClOrdLinkID string `json:"clOrdLinkID,omitempty"` + Account float32 `json:"account,omitempty"` + Symbol string `json:"symbol,omitempty"` + Side string `json:"side,omitempty"` + SimpleOrderQty float64 `json:"simpleOrderQty,omitempty"` + OrderQty float32 `json:"orderQty,omitempty"` + Price float64 `json:"price,omitempty"` + DisplayQty float32 `json:"displayQty,omitempty"` + StopPx float64 `json:"stopPx,omitempty"` + PegOffsetValue float64 `json:"pegOffsetValue,omitempty"` + PegPriceType string `json:"pegPriceType,omitempty"` + Currency string `json:"currency,omitempty"` + SettlCurrency string `json:"settlCurrency,omitempty"` + OrdType string `json:"ordType,omitempty"` + TimeInForce string `json:"timeInForce,omitempty"` + ExecInst string `json:"execInst,omitempty"` + ContingencyType string `json:"contingencyType,omitempty"` + ExDestination string `json:"exDestination,omitempty"` + OrdStatus string `json:"ordStatus,omitempty"` + Triggered string `json:"triggered,omitempty"` + WorkingIndicator bool `json:"workingIndicator,omitempty"` + OrdRejReason string `json:"ordRejReason,omitempty"` + SimpleLeavesQty float64 `json:"simpleLeavesQty,omitempty"` + LeavesQty float32 `json:"leavesQty,omitempty"` + SimpleCumQty float64 `json:"simpleCumQty,omitempty"` + CumQty float32 `json:"cumQty,omitempty"` + AvgPx float64 `json:"avgPx,omitempty"` + MultiLegReportingType string `json:"multiLegReportingType,omitempty"` + Text string `json:"text,omitempty"` + TransactTime time.Time `json:"transactTime,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` +} diff --git a/model_order_book_l2.go b/model_order_book_l2.go new file mode 100644 index 0000000..c91707b --- /dev/null +++ b/model_order_book_l2.go @@ -0,0 +1,19 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type OrderBookL2 struct { + Symbol string `json:"symbol"` + Id float32 `json:"id"` + Side string `json:"side"` + Size float32 `json:"size,omitempty"` + Price float64 `json:"price,omitempty"` +} diff --git a/model_position.go b/model_position.go new file mode 100644 index 0000000..e2d47f2 --- /dev/null +++ b/model_position.go @@ -0,0 +1,110 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Summary of Open and Closed Positions +type Position struct { + Account float32 `json:"account"` + Symbol string `json:"symbol"` + Currency string `json:"currency"` + Underlying string `json:"underlying,omitempty"` + QuoteCurrency string `json:"quoteCurrency,omitempty"` + Commission float64 `json:"commission,omitempty"` + InitMarginReq float64 `json:"initMarginReq,omitempty"` + MaintMarginReq float64 `json:"maintMarginReq,omitempty"` + RiskLimit float32 `json:"riskLimit,omitempty"` + Leverage float64 `json:"leverage,omitempty"` + CrossMargin bool `json:"crossMargin,omitempty"` + DeleveragePercentile float64 `json:"deleveragePercentile,omitempty"` + RebalancedPnl float32 `json:"rebalancedPnl,omitempty"` + PrevRealisedPnl float32 `json:"prevRealisedPnl,omitempty"` + PrevUnrealisedPnl float32 `json:"prevUnrealisedPnl,omitempty"` + PrevClosePrice float64 `json:"prevClosePrice,omitempty"` + OpeningTimestamp time.Time `json:"openingTimestamp,omitempty"` + OpeningQty float32 `json:"openingQty,omitempty"` + OpeningCost float32 `json:"openingCost,omitempty"` + OpeningComm float32 `json:"openingComm,omitempty"` + OpenOrderBuyQty float32 `json:"openOrderBuyQty,omitempty"` + OpenOrderBuyCost float32 `json:"openOrderBuyCost,omitempty"` + OpenOrderBuyPremium float32 `json:"openOrderBuyPremium,omitempty"` + OpenOrderSellQty float32 `json:"openOrderSellQty,omitempty"` + OpenOrderSellCost float32 `json:"openOrderSellCost,omitempty"` + OpenOrderSellPremium float32 `json:"openOrderSellPremium,omitempty"` + ExecBuyQty float32 `json:"execBuyQty,omitempty"` + ExecBuyCost float32 `json:"execBuyCost,omitempty"` + ExecSellQty float32 `json:"execSellQty,omitempty"` + ExecSellCost float32 `json:"execSellCost,omitempty"` + ExecQty float32 `json:"execQty,omitempty"` + ExecCost float32 `json:"execCost,omitempty"` + ExecComm float32 `json:"execComm,omitempty"` + CurrentTimestamp time.Time `json:"currentTimestamp,omitempty"` + CurrentQty float32 `json:"currentQty,omitempty"` + CurrentCost float32 `json:"currentCost,omitempty"` + CurrentComm float32 `json:"currentComm,omitempty"` + RealisedCost float32 `json:"realisedCost,omitempty"` + UnrealisedCost float32 `json:"unrealisedCost,omitempty"` + GrossOpenCost float32 `json:"grossOpenCost,omitempty"` + GrossOpenPremium float32 `json:"grossOpenPremium,omitempty"` + GrossExecCost float32 `json:"grossExecCost,omitempty"` + IsOpen bool `json:"isOpen,omitempty"` + MarkPrice float64 `json:"markPrice,omitempty"` + MarkValue float32 `json:"markValue,omitempty"` + RiskValue float32 `json:"riskValue,omitempty"` + HomeNotional float64 `json:"homeNotional,omitempty"` + ForeignNotional float64 `json:"foreignNotional,omitempty"` + PosState string `json:"posState,omitempty"` + PosCost float32 `json:"posCost,omitempty"` + PosCost2 float32 `json:"posCost2,omitempty"` + PosCross float32 `json:"posCross,omitempty"` + PosInit float32 `json:"posInit,omitempty"` + PosComm float32 `json:"posComm,omitempty"` + PosLoss float32 `json:"posLoss,omitempty"` + PosMargin float32 `json:"posMargin,omitempty"` + PosMaint float32 `json:"posMaint,omitempty"` + PosAllowance float32 `json:"posAllowance,omitempty"` + TaxableMargin float32 `json:"taxableMargin,omitempty"` + InitMargin float32 `json:"initMargin,omitempty"` + MaintMargin float32 `json:"maintMargin,omitempty"` + SessionMargin float32 `json:"sessionMargin,omitempty"` + TargetExcessMargin float32 `json:"targetExcessMargin,omitempty"` + VarMargin float32 `json:"varMargin,omitempty"` + RealisedGrossPnl float32 `json:"realisedGrossPnl,omitempty"` + RealisedTax float32 `json:"realisedTax,omitempty"` + RealisedPnl float32 `json:"realisedPnl,omitempty"` + UnrealisedGrossPnl float32 `json:"unrealisedGrossPnl,omitempty"` + LongBankrupt float32 `json:"longBankrupt,omitempty"` + ShortBankrupt float32 `json:"shortBankrupt,omitempty"` + TaxBase float32 `json:"taxBase,omitempty"` + IndicativeTaxRate float64 `json:"indicativeTaxRate,omitempty"` + IndicativeTax float32 `json:"indicativeTax,omitempty"` + UnrealisedTax float32 `json:"unrealisedTax,omitempty"` + UnrealisedPnl float32 `json:"unrealisedPnl,omitempty"` + UnrealisedPnlPcnt float64 `json:"unrealisedPnlPcnt,omitempty"` + UnrealisedRoePcnt float64 `json:"unrealisedRoePcnt,omitempty"` + SimpleQty float64 `json:"simpleQty,omitempty"` + SimpleCost float64 `json:"simpleCost,omitempty"` + SimpleValue float64 `json:"simpleValue,omitempty"` + SimplePnl float64 `json:"simplePnl,omitempty"` + SimplePnlPcnt float64 `json:"simplePnlPcnt,omitempty"` + AvgCostPrice float64 `json:"avgCostPrice,omitempty"` + AvgEntryPrice float64 `json:"avgEntryPrice,omitempty"` + BreakEvenPrice float64 `json:"breakEvenPrice,omitempty"` + MarginCallPrice float64 `json:"marginCallPrice,omitempty"` + LiquidationPrice float64 `json:"liquidationPrice,omitempty"` + BankruptPrice float64 `json:"bankruptPrice,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` + LastPrice float64 `json:"lastPrice,omitempty"` + LastValue float32 `json:"lastValue,omitempty"` +} diff --git a/model_quote.go b/model_quote.go new file mode 100644 index 0000000..072c88d --- /dev/null +++ b/model_quote.go @@ -0,0 +1,25 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Best Bid/Offer Snapshots & Historical Bins +type Quote struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol"` + BidSize float32 `json:"bidSize,omitempty"` + BidPrice float64 `json:"bidPrice,omitempty"` + AskPrice float64 `json:"askPrice,omitempty"` + AskSize float32 `json:"askSize,omitempty"` +} diff --git a/model_settlement.go b/model_settlement.go new file mode 100644 index 0000000..df39de4 --- /dev/null +++ b/model_settlement.go @@ -0,0 +1,28 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Historical Settlement Data +type Settlement struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol"` + SettlementType string `json:"settlementType,omitempty"` + SettledPrice float64 `json:"settledPrice,omitempty"` + OptionStrikePrice float64 `json:"optionStrikePrice,omitempty"` + OptionUnderlyingPrice float64 `json:"optionUnderlyingPrice,omitempty"` + Bankrupt float32 `json:"bankrupt,omitempty"` + TaxBase float32 `json:"taxBase,omitempty"` + TaxRate float64 `json:"taxRate,omitempty"` +} diff --git a/model_stats.go b/model_stats.go new file mode 100644 index 0000000..091812d --- /dev/null +++ b/model_stats.go @@ -0,0 +1,21 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +// Exchange Statistics +type Stats struct { + RootSymbol string `json:"rootSymbol"` + Currency string `json:"currency,omitempty"` + Volume24h float32 `json:"volume24h,omitempty"` + Turnover24h float32 `json:"turnover24h,omitempty"` + OpenInterest float32 `json:"openInterest,omitempty"` + OpenValue float32 `json:"openValue,omitempty"` +} diff --git a/model_stats_history.go b/model_stats_history.go new file mode 100644 index 0000000..1286aa5 --- /dev/null +++ b/model_stats_history.go @@ -0,0 +1,23 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type StatsHistory struct { + Date time.Time `json:"date"` + RootSymbol string `json:"rootSymbol"` + Currency string `json:"currency,omitempty"` + Volume float32 `json:"volume,omitempty"` + Turnover float32 `json:"turnover,omitempty"` +} diff --git a/model_stats_usd.go b/model_stats_usd.go new file mode 100644 index 0000000..adf1417 --- /dev/null +++ b/model_stats_usd.go @@ -0,0 +1,20 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type StatsUsd struct { + RootSymbol string `json:"rootSymbol"` + Currency string `json:"currency,omitempty"` + Turnover24h float32 `json:"turnover24h,omitempty"` + Turnover30d float32 `json:"turnover30d,omitempty"` + Turnover365d float32 `json:"turnover365d,omitempty"` + Turnover float32 `json:"turnover,omitempty"` +} diff --git a/model_trade.go b/model_trade.go new file mode 100644 index 0000000..c706437 --- /dev/null +++ b/model_trade.go @@ -0,0 +1,29 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Individual & Bucketed Trades +type Trade struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol"` + Side string `json:"side,omitempty"` + Size float32 `json:"size,omitempty"` + Price float64 `json:"price,omitempty"` + TickDirection string `json:"tickDirection,omitempty"` + TrdMatchID string `json:"trdMatchID,omitempty"` + GrossValue float32 `json:"grossValue,omitempty"` + HomeNotional float64 `json:"homeNotional,omitempty"` + ForeignNotional float64 `json:"foreignNotional,omitempty"` +} diff --git a/model_trade_bin.go b/model_trade_bin.go new file mode 100644 index 0000000..a233e16 --- /dev/null +++ b/model_trade_bin.go @@ -0,0 +1,31 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type TradeBin struct { + Timestamp time.Time `json:"timestamp"` + Symbol string `json:"symbol"` + Open float64 `json:"open,omitempty"` + High float64 `json:"high,omitempty"` + Low float64 `json:"low,omitempty"` + Close float64 `json:"close,omitempty"` + Trades float32 `json:"trades,omitempty"` + Volume float32 `json:"volume,omitempty"` + Vwap float64 `json:"vwap,omitempty"` + LastSize float32 `json:"lastSize,omitempty"` + Turnover float32 `json:"turnover,omitempty"` + HomeNotional float64 `json:"homeNotional,omitempty"` + ForeignNotional float64 `json:"foreignNotional,omitempty"` +} diff --git a/model_transaction.go b/model_transaction.go new file mode 100644 index 0000000..d5b5acf --- /dev/null +++ b/model_transaction.go @@ -0,0 +1,30 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type Transaction struct { + TransactID string `json:"transactID"` + Account float32 `json:"account,omitempty"` + Currency string `json:"currency,omitempty"` + TransactType string `json:"transactType,omitempty"` + Amount float32 `json:"amount,omitempty"` + Fee float32 `json:"fee,omitempty"` + TransactStatus string `json:"transactStatus,omitempty"` + Address string `json:"address,omitempty"` + Tx string `json:"tx,omitempty"` + Text string `json:"text,omitempty"` + TransactTime time.Time `json:"transactTime,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` +} diff --git a/model_user.go b/model_user.go new file mode 100644 index 0000000..c0d4453 --- /dev/null +++ b/model_user.go @@ -0,0 +1,36 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +// Account Operations +type User struct { + Id float32 `json:"id,omitempty"` + OwnerId float32 `json:"ownerId,omitempty"` + Firstname string `json:"firstname,omitempty"` + Lastname string `json:"lastname,omitempty"` + Username string `json:"username"` + Email string `json:"email"` + Phone string `json:"phone,omitempty"` + Created time.Time `json:"created,omitempty"` + LastUpdated time.Time `json:"lastUpdated,omitempty"` + Preferences *UserPreferences `json:"preferences,omitempty"` + TFAEnabled string `json:"TFAEnabled,omitempty"` + AffiliateID string `json:"affiliateID,omitempty"` + PgpPubKey string `json:"pgpPubKey,omitempty"` + Country string `json:"country,omitempty"` + GeoipCountry string `json:"geoipCountry,omitempty"` + GeoipRegion string `json:"geoipRegion,omitempty"` + Typ string `json:"typ,omitempty"` +} diff --git a/model_user_commission.go b/model_user_commission.go new file mode 100644 index 0000000..fa5ef81 --- /dev/null +++ b/model_user_commission.go @@ -0,0 +1,18 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type UserCommission struct { + MakerFee float64 `json:"makerFee,omitempty"` + TakerFee float64 `json:"takerFee,omitempty"` + SettlementFee float64 `json:"settlementFee,omitempty"` + MaxFee float64 `json:"maxFee,omitempty"` +} diff --git a/model_user_preferences.go b/model_user_preferences.go new file mode 100644 index 0000000..9884911 --- /dev/null +++ b/model_user_preferences.go @@ -0,0 +1,44 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type UserPreferences struct { + AlertOnLiquidations bool `json:"alertOnLiquidations,omitempty"` + AnimationsEnabled bool `json:"animationsEnabled,omitempty"` + AnnouncementsLastSeen time.Time `json:"announcementsLastSeen,omitempty"` + ChatChannelID float64 `json:"chatChannelID,omitempty"` + ColorTheme string `json:"colorTheme,omitempty"` + Currency string `json:"currency,omitempty"` + Debug bool `json:"debug,omitempty"` + DisableEmails []string `json:"disableEmails,omitempty"` + HideConfirmDialogs []string `json:"hideConfirmDialogs,omitempty"` + HideConnectionModal bool `json:"hideConnectionModal,omitempty"` + HideFromLeaderboard bool `json:"hideFromLeaderboard,omitempty"` + HideNameFromLeaderboard bool `json:"hideNameFromLeaderboard,omitempty"` + HideNotifications []string `json:"hideNotifications,omitempty"` + Locale string `json:"locale,omitempty"` + MsgsSeen []string `json:"msgsSeen,omitempty"` + OrderBookBinning *interface{} `json:"orderBookBinning,omitempty"` + OrderBookType string `json:"orderBookType,omitempty"` + OrderClearImmediate bool `json:"orderClearImmediate,omitempty"` + OrderControlsPlusMinus bool `json:"orderControlsPlusMinus,omitempty"` + ShowLocaleNumbers bool `json:"showLocaleNumbers,omitempty"` + Sounds []string `json:"sounds,omitempty"` + StrictIPCheck bool `json:"strictIPCheck,omitempty"` + StrictTimeout bool `json:"strictTimeout,omitempty"` + TickerGroup string `json:"tickerGroup,omitempty"` + TickerPinned bool `json:"tickerPinned,omitempty"` + TradeLayout string `json:"tradeLayout,omitempty"` +} diff --git a/model_wallet.go b/model_wallet.go new file mode 100644 index 0000000..20cd134 --- /dev/null +++ b/model_wallet.go @@ -0,0 +1,43 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "time" +) + +type Wallet struct { + Account float32 `json:"account"` + Currency string `json:"currency"` + PrevDeposited float32 `json:"prevDeposited,omitempty"` + PrevWithdrawn float32 `json:"prevWithdrawn,omitempty"` + PrevTransferIn float32 `json:"prevTransferIn,omitempty"` + PrevTransferOut float32 `json:"prevTransferOut,omitempty"` + PrevAmount float32 `json:"prevAmount,omitempty"` + PrevTimestamp time.Time `json:"prevTimestamp,omitempty"` + DeltaDeposited float32 `json:"deltaDeposited,omitempty"` + DeltaWithdrawn float32 `json:"deltaWithdrawn,omitempty"` + DeltaTransferIn float32 `json:"deltaTransferIn,omitempty"` + DeltaTransferOut float32 `json:"deltaTransferOut,omitempty"` + DeltaAmount float32 `json:"deltaAmount,omitempty"` + Deposited float32 `json:"deposited,omitempty"` + Withdrawn float32 `json:"withdrawn,omitempty"` + TransferIn float32 `json:"transferIn,omitempty"` + TransferOut float32 `json:"transferOut,omitempty"` + Amount float32 `json:"amount,omitempty"` + PendingCredit float32 `json:"pendingCredit,omitempty"` + PendingDebit float32 `json:"pendingDebit,omitempty"` + ConfirmedDebit float32 `json:"confirmedDebit,omitempty"` + Timestamp time.Time `json:"timestamp,omitempty"` + Addr string `json:"addr,omitempty"` + Script string `json:"script,omitempty"` + WithdrawalLock []string `json:"withdrawalLock,omitempty"` +} diff --git a/model_x_any.go b/model_x_any.go new file mode 100644 index 0000000..77bf26c --- /dev/null +++ b/model_x_any.go @@ -0,0 +1,14 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +type XAny struct { +} diff --git a/response.go b/response.go new file mode 100644 index 0000000..37ecdb1 --- /dev/null +++ b/response.go @@ -0,0 +1,44 @@ +/* + * BitMEX API + * + * ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started Base URI: [https://www.bitmex.com/api/v1](/api/v1) ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section. + * + * API version: 1.2.0 + * Contact: support@bitmex.com + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "net/http" +) + +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the swagger operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +}