Skip to main content

Streaming feed

wscat
-H "Authorization: Bearer {token here}" -c wss://api.lime.co/accounts

Command examples

{ "action":"subscribeBalance","account":"12345678@vision" }
{ "action":"subscribePositions","account":"12345678@vision" }
{ "action":"subscribeOrders","account":"12345678@vision" }
{ "action":"subscribeTrades","account":"12345678@vision" }

{ "action":"unsubscribeBalance","account":"12345678@vision" }
{ "action":"unsubscribePositions","account":"12345678@vision" }
{ "action":"unsubscribeOrders","account":"12345678@vision" }
{ "action":"unsubscribeTrades","account":"12345678@vision" }

Feed example

{
"t":"p",
"data":[{
"account":"12345678@vision",
"positions":[{
"symbol":"AAPL",
"average_open_price":176.8450,
"current_price":187.0050,
"quantity":2,
"security_type":"common_stock"
},
{
"symbol":"AMC",
"average_open_price":8.2800,
"current_price":8.0650,
"quantity":10,
"security_type":"common_stock"
},
{
"symbol":"TSLA",
"average_open_price":233.4900,
"current_price":233.5412,
"quantity":-3,
"security_type":"common_stock"
}]
}]
}
{
"t":"b",
"data":[{
"account_number":"12345678@vision",
"trade_platform":"transaq",
"margin_type":"marginx2",
"restriction":"none",
"account_value_total":27009.0400,
"cash":419.78,
"margin_buying_power":27428.83,
"non_margin_buying_power":13714.41,
"position_market_value":26589.2550,
"unsettled_cash":0,
"cash_to_withdraw":13112.03
}]
}
{
"t":"o",
"data":[{
"account_number":"12345678@vision",
"client_id":"4596252142",
"client_order_id": "01HWYX297HG2J9V607VSY4GQ3S",
"exchange":"Zero Commission",
"quantity":1,
"executed_quantity":0,
"order_status":"new",
"price":378,
"stop_price":0,
"time_in_force":"day",
"order_type":"limit",
"order_side":"buy",
"symbol":"MA",
"executed_price":0,
"tag":"order #11"
}]
}
{
"t":"o",
"data":[{
"account_number":"12345678@vision",
"client_id":"4596252142",
"client_order_id": "01HX6NRN9A6E5N18QACA85BW4T",
"exchange":"auto",
"quantity":1,
"executed_quantity":1,
"order_status":"filled",
"price":378,
"stop_price":0,
"time_in_force":"day",
"order_type":"limit",
"order_side":"buy",
"symbol":"MA",
"executed_price":377.6392,
"executed_timestamp":1644258422,
"tag":""
}]
}
{
"t":"t",
"data":[{
"account_number":"12345678@vision",
"symbol":"MA",
"timestamp":1644258422,
"quantity":1,
"price":377.6392,
"amount":377.6392,
"side":"buy",
"trade_id":"24447436121"
}]
}

If authentication is denied the websocket connection is terminated immediately. The client should implement reconnection logic to maintain the opened connection. The server will disconnect after some inactivity period. Subscription command for an account that has already been subscribed is ignored. Same behavior applies to Unsubscribe. Any recognized command will result an Error sent back to the subscriber.

Request

The following commands are supported:

nametypedescription
actionstringRequired. Possible values are subscribeTrades, subscribeBalance, subscribePositions, subscribeOrders
accountstringRequired. The account number

Response

Position

The server sends a full list of positions for all subscribed accounts on each update of any field value. Since during market hours the prices keep changing the update is going to be sent on each throttling period

nametypedescription
tstringType p
dataarrayAn array of structures where account is an account number and positions is an array of position structures
symbolstringThe security symbol
quantitynumberSigned number of shares or option contracts
average_open_pricenumberAverage historical cost basis
current_pricenumberCurrent price
security_typestringAsset type. Possible values are common_stock, preferred_stock, option

Balance

The server sends a full list of balance for all subscribed accounts on each update of any field value. Since during market hours the prices keep changing the update is going to be sent on each throttling period

nametypedescription
tstringType b
dataarrayAn array of balance structures
account_numberstringThe account number
trade_platformstringThe trading platform this account is traded on
margin_typestringThe margin type, possible values are cash, marginx1, marginx2, daytrader
restrictionstringRestriction level effective on the account, possible values are none - no restrictions, restricted - opening transactions are not allowed but closing orders are accepted, disabled - no activity is allowed in the account, closed - the account is closed
restriction_reasonstringOptional description explaining why the account is restricted
account_value_totalnumberTotal account liquidation value
cashnumberAccount debit balance when negative, credit balance when positive
day_trading_buying_powernumberDay trading buying power for marginable securities
margin_buying_powernumberThe buying power for marginable securities
non_margin_buying_powernumberThe buying power for non-marginable securities
position_market_valuenumberSum of all positions current market values. The value is negative for short positions
unsettled_cashnumberUnsettled cash for cash accounts
cash_to_withdrawnumberCash available to withdraw from the account

Order

The server sends a notification when an order changes status. After initial connection, the server sends a list of all orders in current status on current trading day.

nametypedescription
tstringType o
dataarrayAn array of order structures
account_numberstringThe account number
client_idstringThe order id
client_order_idstringThe client order id
exchangestringThe routing instructions
quantitynumberPositive integer, number of shares, options contracts or multi-leg orders
executed_quantitynumberPositive number of shares or contracts executed by this time
order_statusstringThe order status. Possible values are pending_new, new, partially_filled, filled, replaced, done_for_day, pending_cancel, canceled, rejected, suspended
pricenumberLimit price if applicable
stop_pricenumberStop price is applicable
time_in_forcestringOrder duration instructions. Possible values are day - regular hours, ext - extended hours, on-open - opening auction, on-close - closing auction, ioc - immediate or cancel, fok - fill or kill
order_typestringThe order type. Possible values are limit, market
order_sidestringSide of the order. Possible values are buy, sell
symbolstringThe security symbol
executed_pricenumberThe average price of execution, only populated when an order has been executed, partially or fully
executed_timestampnumberUnix time stamp of the last execution, only populated when an order has been executed, partially or fully
tagstringOrder tag if specified
legsarrayArray of legs in a multi-leg order

Legs array element:

nametypedescription
symbolstringLeg security symbol
quantitynumberPositive integer, leg ratio quantity
sidestringSide of the leg. Available values are buy and sell

Trade

The server sends a notification when a trade executes. After initial connection, the server sends a list of all trades on current trading day.

nametypedescription
tstringType t
dataarrayAn array of trade structures
account_numberstringThe account number
symbolstringThe security symbol
timestampnumberUnix time stamp of the trade
quantitynumberNumber of shares or option contracts, negative for sells, positive for buys
pricenumberThe trade price
amountnumberThe trade amount, which is the quantity multiplied by the lot size and price
sidestringThe trade side. Possible values are buy or sell
trade_idstringThe trade id

Error

namedescription
tType e
codeError code
descriptionError description