Account Subscriptions

SubscribeAsset

Purpose

Subscribes the connected client to asset events and records the subscription locally.

Signature

func (c *PushClient) SubscribeAsset(account string) error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

ParameterTypeRequiredSDK defaultConstraints
accountstringYesNoneAccount ID; an empty string uses the configured default account

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.SubscribeAsset(""); err != nil {
	log.Fatal(err)
}

Callback Data Example

{
    "account": "13810712",
    "currency": "USD",
    "segment": "S",
    "availableFunds": 2285040.55,
    "netLiquidation": 2285529.37,
    "buyingPower": 9140162.19,
    "cashBalance": 2284275.24,
    "grossPositionValue": 1143.04,
    "timestamp": "1669888806020"
}

UnsubscribeAsset

Purpose

Unsubscribes the connected client from asset events and removes the local subscription record.

Signature

func (c *PushClient) UnsubscribeAsset() error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

No parameters.

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.UnsubscribeAsset(); err != nil {
	log.Fatal(err)
}

SubscribePosition

Purpose

Subscribes the connected client to position events and records the subscription locally.

Signature

func (c *PushClient) SubscribePosition(account string) error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

ParameterTypeRequiredSDK defaultConstraints
accountstringYesNoneAccount ID; an empty string uses the configured default account

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.SubscribePosition(""); err != nil {
	log.Fatal(err)
}

Callback Data Example

{
    "account": "13810712",
    "symbol": "AAPL",
    "identifier": "AAPL",
    "market": "US",
    "secType": "STK",
    "positionQty": 4.0,
    "averageCost": 75.0,
    "latestPrice": 147.23,
    "marketValue": 588.92,
    "unrealizedPnl": 288.92,
    "timestamp": "1669888802018"
}

UnsubscribePosition

Purpose

Unsubscribes the connected client from position events and removes the local subscription record.

Signature

func (c *PushClient) UnsubscribePosition() error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

No parameters.

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.UnsubscribePosition(); err != nil {
	log.Fatal(err)
}

SubscribeOrder

Purpose

Subscribes the connected client to order events and records the subscription locally.

Signature

func (c *PushClient) SubscribeOrder(account string) error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

ParameterTypeRequiredSDK defaultConstraints
accountstringYesNoneAccount ID; an empty string uses the configured default account

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.SubscribeOrder(""); err != nil {
	log.Fatal(err)
}

Callback Data Example

{
    "id": "28875370355884032",
    "account": "736845",
    "symbol": "CL",
    "action": "BUY",
    "orderType": "LMT",
    "totalQuantity": "1",
    "filledQuantity": "1",
    "avgFillPrice": 77.76,
    "status": "Filled",
    "timestamp": "1669200782221"
}

UnsubscribeOrder

Purpose

Unsubscribes the connected client from order events and removes the local subscription record.

Signature

func (c *PushClient) UnsubscribeOrder() error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

No parameters.

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.UnsubscribeOrder(); err != nil {
	log.Fatal(err)
}

SubscribeTransaction

Purpose

Subscribes the connected client to transaction events and records the subscription locally.

Signature

func (c *PushClient) SubscribeTransaction(account string) error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

ParameterTypeRequiredSDK defaultConstraints
accountstringYesNoneAccount ID; an empty string uses the configured default account

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.SubscribeTransaction(""); err != nil {
	log.Fatal(err)
}

UnsubscribeTransaction

Purpose

Unsubscribes the connected client from transaction events and removes the local subscription record.

Signature

func (c *PushClient) UnsubscribeTransaction() error

Requires an authenticated push connection and an accessible trading account. An empty account uses the configured account.

Parameters

No parameters.

Returns

error; nil means the message was written to the current connection.

Invocation example

if err := pc.UnsubscribeTransaction(); err != nil {
	log.Fatal(err)
}


Did this page help you?