rest

package
v0.0.0-...-39def3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultUrl = "localhost:5000"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(url string, ssl bool) *Conn

func (*Conn) Do

func (c *Conn) Do(
	method string,
	url *bytebufferpool.ByteBuffer,
	handle func(status int, body []byte, err error) error,
) error

func (*Conn) DoRequest

func (c *Conn) DoRequest(
	method string,
	url *bytebufferpool.ByteBuffer,
	doc []byte,
	handle func(status int, body []byte, err error) error,
) error

func (*Conn) Fyi_Deliveryoptions_DeviceId_DELETE

func (c *Conn) Fyi_Deliveryoptions_DeviceId_DELETE(

	deviceId string,
) (
	_200 Any,
	err error,
)

func (*Conn) Fyi_Deliveryoptions_Device_POST

func (c *Conn) Fyi_Deliveryoptions_Device_POST(
	request *Fyi_Deliveryoptions_Device_POST_Request,
) (
	_200 *Fyi_Deliveryoptions_Device_POST_200,
	err error,
)

func (*Conn) Fyi_Deliveryoptions_Email_PUT

func (c *Conn) Fyi_Deliveryoptions_Email_PUT(

	enabled string,
) (
	_200 *Fyi_Deliveryoptions_Email_PUT_200,
	err error,
)

func (*Conn) Fyi_Deliveryoptions_GET

func (c *Conn) Fyi_Deliveryoptions_GET() (
	_200 *Fyi_Deliveryoptions_GET_200,
	err error,
)

options for sending fyis to email and other devices

func (*Conn) Fyi_Disclaimer_Typecode_GET

func (c *Conn) Fyi_Disclaimer_Typecode_GET(

	typecode string,
) (
	_200 *Fyi_Disclaimer_Typecode_GET_200,
	err error,
)

func (*Conn) Fyi_Disclaimer_Typecode_PUT

func (c *Conn) Fyi_Disclaimer_Typecode_PUT(

	typecode string,
) (
	_200 *Fyi_Disclaimer_Typecode_PUT_200,
	err error,
)

func (*Conn) Fyi_Notifications_GET

func (c *Conn) Fyi_Notifications_GET(

	exclude string,

	include string,

	max string,
) (
	_200 Notifications_List,
	err error,
)

func (*Conn) Fyi_Notifications_More_GET

func (c *Conn) Fyi_Notifications_More_GET(

	id string,
) (
	_200 Notifications_List,
	err error,
)

func (*Conn) Fyi_Notifications_NotificationId_PUT

func (c *Conn) Fyi_Notifications_NotificationId_PUT(

	notificationId string,
) (
	_200 Any,
	err error,
)

func (*Conn) Fyi_Settings_GET

func (c *Conn) Fyi_Settings_GET() (
	_200 Fyi_Settings_GET_200_List,
	err error,
)

Return the current choices of subscriptions, we can toggle the option

func (*Conn) Fyi_Settings_Typecode_POST

func (c *Conn) Fyi_Settings_Typecode_POST(

	typecode string,
	request *Fyi_Settings_Typecode_POST_Request,
) (
	_200 Any,
	err error,
)

Configure which typecode you would like to enable/disable.

func (*Conn) Fyi_Unreadnumber_GET

func (c *Conn) Fyi_Unreadnumber_GET() (
	_200 *Fyi_Unreadnumber_GET_200,
	err error,
)

Returns the total number of unread fyis

func (*Conn) Ibcust_Entity_Info_GET

func (c *Conn) Ibcust_Entity_Info_GET() (
	_200 Ibcust_Entity_Info_GET_200_List,
	err error,
)

Returns Applicant Id with all owner related entities

func (*Conn) Iserver_Account_AccountId_Alert_Activate_POST

func (c *Conn) Iserver_Account_AccountId_Alert_Activate_POST(

	accountId string,
	request *Iserver_Account_AccountId_Alert_Activate_POST_Request,
) (
	_200 *Iserver_Account_AccountId_Alert_Activate_POST_200,
	err error,
)

Please note, if alertId is 0, it will activate/deactivate all alerts

func (*Conn) Iserver_Account_AccountId_Alert_AlertId_DELETE

func (c *Conn) Iserver_Account_AccountId_Alert_AlertId_DELETE(

	accountId string,

	alertId string,
) (
	_200 *Iserver_Account_AccountId_Alert_AlertId_DELETE_200,
	err error,
)

Please be careful, if alertId is 0, it will delete all alerts

func (*Conn) Iserver_Account_AccountId_Alert_POST

func (c *Conn) Iserver_Account_AccountId_Alert_POST(

	accountId string,
	request *AlertRequest,
) (
	_200 *Iserver_Account_AccountId_Alert_POST_200,
	err error,
)

Please note here, DO NOT pass orderId when creating a new alert, toolId is only required for MTA alert

func (*Conn) Iserver_Account_AccountId_Alerts_GET

func (c *Conn) Iserver_Account_AccountId_Alerts_GET(

	accountId string,
) (
	_200 Iserver_Account_AccountId_Alerts_GET_200_List,
	err error,
)

The response will contain both active and inactive alerts, but it won't have MTA alert

func (*Conn) Iserver_Account_AccountId_Order_OrderId_DELETE

func (c *Conn) Iserver_Account_AccountId_Order_OrderId_DELETE(

	accountId string,

	orderId string,
) (
	_200 *Iserver_Account_AccountId_Order_OrderId_DELETE_200,
	err error,
)

Cancels an open order. Must call /iserver/accounts endpoint prior to cancelling an order. Use /iservers/account/orders endpoint to review open-order(s) and get latest order status.

func (*Conn) Iserver_Account_AccountId_Order_OrderId_POST

func (c *Conn) Iserver_Account_AccountId_Order_OrderId_POST(

	accountId string,

	orderId string,
	request *ModifyOrder,
) (
	_200 Iserver_Account_AccountId_Order_OrderId_POST_200_List,
	err error,
)

Modifies an open order. Must call /iserver/accounts endpoint prior to modifying an order. Use /iservers/account/orders endpoint to review open-order(s).

func (*Conn) Iserver_Account_AccountId_Order_POST

func (c *Conn) Iserver_Account_AccountId_Order_POST(

	accountId string,
	request *OrderRequest,
) (
	_200 Iserver_Account_AccountId_Order_POST_200_List,
	err error,
)

Please note here, sometimes this endpoint alone can't make sure you submit the order successfully, you could receive some questions in the response, you have to to answer them in order to submit the order successfully. You can use "/iserver/reply/{replyid}" endpoint to answer questions

func (*Conn) Iserver_Account_AccountId_Order_Whatif_POST

func (c *Conn) Iserver_Account_AccountId_Order_Whatif_POST(

	accountId string,
	request *OrderRequest,
) (
	_200 *Iserver_Account_AccountId_Order_Whatif_POST_200,
	err error,
)

This endpoint allows you to preview order without actually submitting the order and you can get commission information in the response.

func (*Conn) Iserver_Account_AccountId_Orders_POST

func (c *Conn) Iserver_Account_AccountId_Orders_POST(

	accountId string,
	request *Iserver_Account_AccountId_Orders_POST_Request,
) (
	_200 Iserver_Account_AccountId_Orders_POST_200_List,
	err error,
)

You can pass a list of orders here

func (*Conn) Iserver_Account_Alert_Id_GET

func (c *Conn) Iserver_Account_Alert_Id_GET(

	id string,
) (
	_200 *AlertResponse,
	err error,
)

Use the endpoint /iserver/account/:accountId/alerts to receive the alert id. The order_id in the response is the alert id.

func (*Conn) Iserver_Account_Mta_GET

func (c *Conn) Iserver_Account_Mta_GET() (
	_200 *AlertResponse,
	err error,
)

Each login user only has one mobile trading assistant (MTA) alert with it's own unique tool id. The tool id cannot be changed. When modified a new order Id is generated. MTA alerts can not be created or deleted. If you call delete /iserver/account/:accountId/alert/:alertId, it will reset MTA to default. See [here](https://www.interactivebrokers.com/en/software/mobileiphonemobile/mobileiphone.htm#monitor/trading-assistant.htm) for more information on MTA alerts.

func (*Conn) Iserver_Account_Orders_FaGroup_POST

func (c *Conn) Iserver_Account_Orders_FaGroup_POST(

	faGroup string,
	request *OrderRequest,
) (
	_200 Iserver_Account_Orders_FaGroup_POST_200_List,
	err error,
)

Financial Advisors can use this endpoint to place an order for a specified group. To place an order for a specified account use the endpoint /iserver/account/{accountId}/order. More information about groups can be found in the [TWS Users' Guide:](https://guides.interactivebrokers.com/twsguide/twsguide.htm#usersguidebook/financialadvisors/create_an_account_group_for_share_allocation.htm).

func (*Conn) Iserver_Account_Orders_GET

func (c *Conn) Iserver_Account_Orders_GET(
	request *Iserver_Account_Orders_GET_Request,
) (
	_200 *Iserver_Account_Orders_GET_200,
	err error,
)

The endpoint is meant to be used in polling mode, e.g. requesting every x seconds. The response will contain two objects, one is notification, the other is orders.

Orders is the list of live orders (cancelled, filled, submitted). Notifications contains information about execute orders as they happen, see status field. To receive streaming live orders the endpoint /ws can be used. Refer to [Streaming WebSocket Data](https://interactivebrokers.github.io/cpwebapi/RealtimeSubscription.html) for details.

func (*Conn) Iserver_Account_POST

func (c *Conn) Iserver_Account_POST(
	request *SetAccount,
) (
	_200 *Iserver_Account_POST_200,
	err error,
)

If an user has multiple accounts, and user wants to get orders, trades, etc. of an account other than currently selected account, then user can update the currently selected account using this API and then can fetch required information for the newly updated account.

func (*Conn) Iserver_Account_Pnl_Partitioned_GET

func (c *Conn) Iserver_Account_Pnl_Partitioned_GET() (
	_200 *Iserver_Account_Pnl_Partitioned_GET_200,
	err error,
)

Returns an object containing PnL for the selected account and its models (if any). To receive streaming PnL the endpoint /ws can be used. Refer to [Streaming WebSocket Data](https://interactivebrokers.github.io/cpwebapi/RealtimeSubscription.html) for details.

func (*Conn) Iserver_Account_Trades_GET

func (c *Conn) Iserver_Account_Trades_GET() (
	_200 Iserver_Account_Trades_GET_200_List,
	err error,
)

Returns a list of trades for the currently selected account for current day and six previous days. It is advised to call this endpoint once per session.

func (*Conn) Iserver_Accounts_GET

func (c *Conn) Iserver_Accounts_GET() (
	_200 *Iserver_Accounts_GET_200,
	err error,
)

Returns a list of accounts the user has trading access to, their respective aliases and the currently selected account. Note this endpoint must be called before modifying an order or querying open orders.

func (*Conn) Iserver_Auth_Status_POST

func (c *Conn) Iserver_Auth_Status_POST() (
	_200 *AuthStatus,
	err error,
)

Current Authentication status to the Brokerage system. Market Data and Trading is not possible if not authenticated, e.g. authenticated shows false

func (*Conn) Iserver_Contract_Conid_InfoAndRules_GET

func (c *Conn) Iserver_Contract_Conid_InfoAndRules_GET(

	conid string,

	isBuy bool,
) (
	_200 *Iserver_Contract_Conid_InfoAndRules_GET_200,
	err error,
)

Returns trading related rules and info for contract

func (*Conn) Iserver_Contract_Conid_Info_GET

func (c *Conn) Iserver_Contract_Conid_Info_GET(

	conid string,
) (
	_200 *Contract,
	err error,
)

Using the Contract Identifier get contract info. You can use this to prefill your order before you submit an order

func (*Conn) Iserver_Marketdata_Conid_Unsubscribe_GET

func (c *Conn) Iserver_Marketdata_Conid_Unsubscribe_GET(

	conid string,
) (
	_200 *Iserver_Marketdata_Conid_Unsubscribe_GET_200,
	err error,
)

Cancel market data for given conid. To cancel all market data request(s), see /iserver/marketdata/unsubscribeall.

func (*Conn) Iserver_Marketdata_History_GET

func (c *Conn) Iserver_Marketdata_History_GET(

	conid string,

	exchange string,

	period string,

	bar string,

	outsideRth bool,
) (
	_200 *HistoryData,
	_429 *Iserver_Marketdata_History_GET_429,
	_500 *SystemError,
	err error,
)

Get historical market Data for given conid, length of data is controlled by 'period' and 'bar'. Formatted as: min=minute, h=hour, d=day, w=week, m=month, y=year e.g. period =1y with bar =1w returns 52 data points (Max of 1000 data points supported). **Note**: There's a limit of 5 concurrent requests. Excessive requests will return a 'Too many requests' status 429 response.

func (*Conn) Iserver_Marketdata_Snapshot_GET

func (c *Conn) Iserver_Marketdata_Snapshot_GET(

	conids string,

	since int64,

	fields string,
) (
	_200 Iserver_Marketdata_Snapshot_GET_200_List,
	_400 *Iserver_Marketdata_Snapshot_GET_400,
	err error,
)

Get Market Data for the given conid(s). The endpoint will return by default bid, ask, last, change, change pct, close, listing exchange. See response fields for a list of available fields that can be request via fields argument. The endpoint /iserver/accounts must be called prior to /iserver/marketdata/snapshot. For derivative contracts the endpoint /iserver/secdef/search must be called first. First /snapshot endpoint call for given conid will initiate the market data request.

To receive all available fields the /snapshot endpoint will need to be called several times. To receive streaming market data the endpoint /ws can be used. Refer to [Streaming WebSocket Data](https://interactivebrokers.github.io/cpwebapi/RealtimeSubscription.html) for details.

func (*Conn) Iserver_Marketdata_Unsubscribeall_GET

func (c *Conn) Iserver_Marketdata_Unsubscribeall_GET() (
	_200 *Iserver_Marketdata_Unsubscribeall_GET_200,
	err error,
)

Cancel all market data request(s). To cancel market data for given conid, see /iserver/marketdata/{conid}/unsubscribe.

func (*Conn) Iserver_Reauthenticate_POST

func (c *Conn) Iserver_Reauthenticate_POST() (
	_200 *AuthStatus,
	err error,
)

When using the CP Gateway, this endpoint provides a way to reauthenticate to the Brokerage system as long as there is a valid SSO session, see /sso/validate.

func (*Conn) Iserver_Reply_Replyid_POST

func (c *Conn) Iserver_Reply_Replyid_POST(

	replyid string,
	request *Iserver_Reply_Replyid_POST_Request,
) (
	_200 Iserver_Reply_Replyid_POST_200_List,
	_400 *Iserver_Reply_Replyid_POST_400,
	err error,
)

Reply to questions when placing orders and submit orders

func (*Conn) Iserver_Scanner_Params_GET

func (c *Conn) Iserver_Scanner_Params_GET() (
	_200 *Iserver_Scanner_Params_GET_200,
	err error,
)

Returns an object contains four lists contain all parameters for scanners

func (*Conn) Iserver_Scanner_Run_POST

func (c *Conn) Iserver_Scanner_Run_POST(
	request *ScannerParams,
) (
	_200 Iserver_Scanner_Run_POST_200_List,
	err error,
)

func (*Conn) Iserver_Secdef_Info_GET

func (c *Conn) Iserver_Secdef_Info_GET(

	conid string,

	sectype string,

	month string,

	exchange string,

	strike string,

	right string,
) (
	_200 Iserver_Secdef_Info_GET_200_List,
	_500 *Iserver_Secdef_Info_GET_500,
	err error,
)

Provides Contract Details of Futures, Options, Warrants, Cash and CFDs based on conid. To get the strike price for Options/Warrants use "/iserver/secdef/strikes" endpoint. Must call /secdef/search for the underlying contract first.

func (*Conn) Iserver_Secdef_Search_POST

func (c *Conn) Iserver_Secdef_Search_POST(
	request *Iserver_Secdef_Search_POST_Request,
) (
	_200 Iserver_Secdef_Search_POST_200_List,
	_500 *Iserver_Secdef_Search_POST_500,
	err error,
)

Search by underlying or company name. Relays back what derivative contract(s) it has. This endpoint must be called before using /secdef/info

func (*Conn) Iserver_Secdef_Strikes_GET

func (c *Conn) Iserver_Secdef_Strikes_GET(

	conid string,

	sectype string,

	month string,

	exchange string,
) (
	_200 *Iserver_Secdef_Strikes_GET_200,
	_500 *Iserver_Secdef_Strikes_GET_500,
	err error,
)

Query strikes for Options/Warrants. For available contract months and exchanges use "/iserver/secdef/search"

func (*Conn) Logout_POST

func (c *Conn) Logout_POST() (
	_200 *Logout_POST_200,
	err error,
)

Logs the user out of the gateway session. Any further activity requires re-authentication.

func (*Conn) Pa_Performance_POST

func (c *Conn) Pa_Performance_POST(
	request *Pa_Performance_POST_Request,
) (
	_200 *Performance,
	err error,
)

Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.

func (*Conn) Pa_Summary_POST

func (c *Conn) Pa_Summary_POST(
	request *Pa_Summary_POST_Request,
) (
	_200 *Summary,
	err error,
)

Returns a summary of all account balances for the given accounts, if more than one account is passed, the result is consolidated.

func (*Conn) Pa_Transactions_POST

func (c *Conn) Pa_Transactions_POST(
	request *Pa_Transactions_POST_Request,
) (
	_200 *Transactions,
	err error,
)

transaction history for a given number of conids and accounts. Types of transactions include dividend payments, buy and sell transactions, transfers.

func (*Conn) Portfolio_AccountId_Allocation_GET

func (c *Conn) Portfolio_AccountId_Allocation_GET(

	accountId string,
) (
	_200 Allocation_List,
	err error,
)

Information about the account's portfolio allocation by Asset Class, Industry and Category. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_AccountId_Ledger_GET

func (c *Conn) Portfolio_AccountId_Ledger_GET(

	accountId string,
) (
	_200 *Portfolio_AccountId_Ledger_GET_200,
	err error,
)

Information regarding settled cash, cash balances, etc. in the account's base currency and any other cash balances hold in other currencies. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint. The list of supported currencies is available at https://www.interactivebrokers.com/en/index.php?f=3185.

func (*Conn) Portfolio_AccountId_Meta_GET

func (c *Conn) Portfolio_AccountId_Meta_GET(

	accountId string,
) (
	_200 Accounts_List,
	err error,
)

Account information related to account Id /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_AccountId_Position_Conid_GET

func (c *Conn) Portfolio_AccountId_Position_Conid_GET(

	accountId string,

	conid int64,
) (
	_200 Position_List,
	err error,
)

Returns a list of all positions matching the conid. For portfolio models the conid could be in more than one model, returning an array with the name of the model it belongs to. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_AccountId_Positions_Invalidate_POST

func (c *Conn) Portfolio_AccountId_Positions_Invalidate_POST(

	accountId string,
) (
	_200 Any,
	err error,
)

func (*Conn) Portfolio_AccountId_Positions_PageId_GET

func (c *Conn) Portfolio_AccountId_Positions_PageId_GET(

	accountId string,

	pageId string,

	model string,

	sort string,

	direction string,

	period string,
) (
	_200 Position_List,
	err error,
)

Returns a list of positions for the given account. The endpoint supports paging, page's default size is 30 positions. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_AccountId_Summary_GET

func (c *Conn) Portfolio_AccountId_Summary_GET(

	accountId string,
) (
	_200 *Portfolio_AccountId_Summary_GET_200,
	err error,
)

Returns information about margin, cash balances and other information related to specified account. See also /portfolio/{accountId}/ledger. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_Accounts_GET

func (c *Conn) Portfolio_Accounts_GET() (
	_200 Accounts_List,
	err error,
)

In non-tiered account structures, returns a list of accounts for which the user can view position and account information. This endpoint must be called prior to calling other /portfolio endpoints for those accounts. For querying a list of accounts which the user can trade, see /iserver/accounts. For a list of subaccounts in tiered account structures (e.g. financial advisor or ibroker accounts) see /portfolio/subaccounts.

func (*Conn) Portfolio_Allocation_POST

func (c *Conn) Portfolio_Allocation_POST(
	request *Portfolio_Allocation_POST_Request,
) (
	_200 Allocation_List,
	err error,
)

Similar to /portfolio/{accountId}/allocation but returns a consolidated view of of all the accounts returned by /portfolio/accounts. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_Positions_Conid_GET

func (c *Conn) Portfolio_Positions_Conid_GET(

	conid int64,
) (
	_200 *Portfolio_Positions_Conid_GET_200,
	err error,
)

Returns an object of all positions matching the conid for all the selected accounts. For portfolio models the conid could be in more than one model, returning an array with the name of the model it belongs to. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.

func (*Conn) Portfolio_Subaccounts_GET

func (c *Conn) Portfolio_Subaccounts_GET() (
	_200 *Account,
	err error,
)

Used in tiered account structures (such as financial advisor and ibroker accounts) to return a list of sub-accounts for which the user can view position and account-related information. This endpoint must be called prior to calling other /portfolio endpoints for those subaccounts. To query a list of accounts the user can trade, see /iserver/accounts.

func (*Conn) Sso_Validate_GET

func (c *Conn) Sso_Validate_GET() (
	_200 *Sso_Validate_GET_200,
	err error,
)

Validates the current session for the SSO user

func (*Conn) Tickle_POST

func (c *Conn) Tickle_POST() (
	_200 *Tickle_POST_200,
	err error,
)

If the gateway has not received any requests for several minutes an open session will automatically timeout. The tickle endpoint pings the server to prevent the session from ending.

func (*Conn) Trsrv_Futures_GET

func (c *Conn) Trsrv_Futures_GET(

	symbols string,
) (
	_200 *Trsrv_Futures_GET_200,
	_500 *Trsrv_Futures_GET_500,
	err error,
)

Returns a list of non-expired future contracts for given symbol(s)

func (*Conn) Trsrv_Secdef_POST

func (c *Conn) Trsrv_Secdef_POST(
	request *Trsrv_Secdef_POST_Request,
) (
	_200 Secdef_List,
	err error,
)

Returns a list of security definitions for the given conids

func (*Conn) Trsrv_Secdef_Schedule_GET

func (c *Conn) Trsrv_Secdef_Schedule_GET(

	assetClass string,

	symbol string,

	exchange string,
) (
	_200 *Trsrv_Secdef_Schedule_GET_200,
	err error,
)

Returns the trading schedule up to a month for the requested contract

func (*Conn) Trsrv_Stocks_GET

func (c *Conn) Trsrv_Stocks_GET(

	symbols string,
) (
	_200 *Trsrv_Stocks_GET_200,
	_500 *Trsrv_Stocks_GET_500,
	err error,
)

Returns an object contains all stock contracts for given symbol(s)

func (*Conn) Ws_POST

func (c *Conn) Ws_POST() (
	err error,
)

The streaming API is documented under [Streaming WebSocket Data](https://interactivebrokers.github.io/cpwebapi/RealtimeSubscription.html) for details.

type StatusCodeError

type StatusCodeError struct {
	Code int
}

func (StatusCodeError) Error

func (s StatusCodeError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL