Горячие клавиши

← и →: предыдущая и следующая глава

S или /: поиск по книге

?: показать эту подсказку

Esc: закрыть подсказку или поиск

Справочник API: Gateway (gRPC)

Контракт между ботом и гейтвеем: сервисы, вызовы, сообщения и перечисления. Страница собрана из файлов .proto в каталоге proto/ репозитория, руками не правится: сборка книги сравнивает ее с файлами и падает, если они разошлись.

Как подключиться, какие заголовки слать и в каком порядке вызывать: Подключить бота. Как устроены события и что делать с Gap и Lagged: События и сверка после перезапуска. Что значит каждая ошибка и что с ней делать: Ошибки и что с ними делать.

В файлах три пакета описаний:

ФайлДля когоЧто в нем
gateway.protoботысервис Gateway: заявки, счет, рынок, подписки, Health и поток Events
types.protoботызначения, которыми обмениваются вызовы: инструменты, заявки, портфель, рыночные данные
service.protoкоманды brokapiсервис Service у службы brokapi up. Боту он не нужен

Описания и комментарии в файлах английские, так они и показаны ниже: это тот самый текст, который увидит ваш генератор кода.

Gateway: служба для ботов и события

Файл proto/brokapi/gateway/v1/gateway.proto, пакет brokapi.gateway.v1.

The brokapi gateway: one process that holds the connection to one broker account and serves any number of bots.

How a bot uses it:

  1. Connect to the Unix socket of the gateway (or 127.0.0.1 on Windows) and send two metadata headers with every
     call: `authorization: Bearer <the key from the access.key file>` and `x-brokapi-bot: <name of the bot>`.
  2. Open `Events` first, then subscribe. The first frame of `Events` says the stream is registered. Events that
     happen after it are yours.
  3. Call `Reconcile` once before any trading command.

An error of the library comes back as a gRPC status with the `brokapi-error-bin` trailer, an `ErrorDetail`. The
status code is a hint for generic tools. The detail is the whole error: what a bot needs to decide whether to retry
is in `kind`.

Сервис Gateway

A call named like the type it returns (Portfolio, OrderBook, TradingParams, TradingStatus, Schedule) names the type with its full name: inside the service the short name is the call, and protoc and buf refuse it. tools/proto-check.

Orders: a command is never repeated by the gateway, and it runs to its end if you stop waiting

Stop orders

ВызовЗапросОтветОписание
PlaceStopPlaceStopOrderRequestOrderAck
CancelStopCancelStopRequestCancelResponse
ActiveStopOrdersActiveOrdersRequestActiveStopOrdersResponse
SubscribeStopOrdersSubscribeRequestSubscribeResponse

Account

ВызовЗапросОтветОписание
PortfolioAccountRequestPortfolio
PositionsAccountRequestPositionsResponse
BalancesAccountRequestBalancesResponse
ExecutionsExecutionsRequestExecutionsResponse
SubscribeExecutionsSubscribeRequestSubscribeResponse
SubscribePortfolioSubscribeRequestSubscribeResponse

Market data

ВызовЗапросОтветОписание
OrderBookOrderBookRequestOrderBook
LastTradesLastTradesRequestLastTradesResponse
CandlesCandlesRequestCandlesResponse
SubscribeOrderBookSubscribeInstrumentRequestSubscribeResponse
SubscribeMarketTradesSubscribeInstrumentRequestSubscribeResponse
SubscribeQuotesSubscribeInstrumentRequestSubscribeResponse
SubscribeCandlesSubscribeCandlesRequestSubscribeResponse
UnsubscribeUnsubscribeRequestUnsubscribeResponseLets go of a subscription this bot holds. The same request of two bots is one subscription at the broker with two owners: it is closed when the last owner lets go, and a bot that does not hold it gets the refusal not_your_subscription. The subscriptions of a bot are also let go when the bot is gone (its event stream ended and did not come back within the grace period of the gateway). The events of a subscription go to every bot that reads the stream, whoever asked for it.

Instruments

ВызовЗапросОтветОписание
ResolveInstrumentResolveInstrumentRequestInstrumentId
FindFindRequestFindResponse
GetInstrumentInstrumentRequestInstrument
TradingParamsInstrumentRequestTradingParams
TradingStatusInstrumentRequestTradingStatus
ScheduleScheduleRequestSchedule

The rest

ВызовЗапросОтветОписание
RawRawRequestRawResponseAny method of the broker’s own API by name, arguments and reply as JSON text. See the page of the broker.
CapsCapsRequestCapsResponse
HealthHealthRequestHealthResponseWorks while the gateway starts: this is how a bot waits for it.
EventsEventsRequestпоток EventFrameThe events of the connection. See EventsRequest.

CancelRequest

ПолеТип№Описание
cidstring1

CancelResponse

Без полей.

OrderStateRequest

ПолеТип№Описание
cidstring1

ActiveOrdersRequest

Без полей.

ActiveOrdersResponse

ПолеТип№Описание
ordersсписок OrderSnapshot1

ActiveStopOrdersResponse

ПолеТип№Описание
stop_ordersсписок StopOrderSnapshot1

ReconcileRequest

ПолеТип№Описание
ledgerсписок string1The ids of the orders you placed and have not seen end.
include_journalbool2Add the orders of the gateway’s own journal (all bots) to the ledger. Without it the orders of the other bots come back as foreign.

CancelStopRequest

ПолеТип№Описание
stopStopOrderRef1

AccountRequest

Без полей.

PositionsResponse

ПолеТип№Описание
positionsсписок Position1

BalancesResponse

ПолеТип№Описание
balancesсписок Balance1

ExecutionsRequest

ПолеТип№Описание
rangeTimeRange1

ExecutionsResponse

ПолеТип№Описание
executionsсписок Execution1

OrderBookRequest

ПолеТип№Описание
instrumentInstrumentId1
depthuint322

LastTradesRequest

ПолеТип№Описание
instrumentInstrumentId1
limituint322

LastTradesResponse

ПолеТип№Описание
tradesсписок MarketTrade1

CandlesRequest

ПолеТип№Описание
instrumentInstrumentId1
timeframeTimeframe2
rangeTimeRange3

CandlesResponse

ПолеТип№Описание
candlesсписок Candle1

SubscribeRequest

ПолеТип№Описание
optsSubscribeOpts1

SubscribeInstrumentRequest

ПолеТип№Описание
instrumentInstrumentId1
optsSubscribeOpts2

SubscribeCandlesRequest

ПолеТип№Описание
instrumentInstrumentId1
timeframeTimeframe2
optsSubscribeOpts3

SubscribeResponse

ПолеТип№Описание
subuint641The id that marks the events of this subscription (Event.sub).

UnsubscribeRequest

ПолеТип№Описание
subuint641

UnsubscribeResponse

Без полей.

ResolveInstrumentRequest

ПолеТип№Описание
tickerstring1

FindRequest

ПолеТип№Описание
queryInstrumentQuery1

FindResponse

ПолеТип№Описание
instrumentsсписок Instrument1

InstrumentRequest

ПолеТип№Описание
instrumentInstrumentId1

ScheduleRequest

ПолеТип№Описание
exchangestring1
rangeTimeRange2

RawRequest

ПолеТип№Описание
methodstring1The name of the method of the broker’s API, as the broker names it.
args_jsonstring2The arguments as a JSON object, empty for none.
commandbool3True when the call changes something at the broker: a lost reply is then Unknown and the call is not repeated.

RawResponse

ПолеТип№Описание
reply_jsonstring1

CapsRequest

Без полей.

CapsResponse

ПолеТип№Описание
mdMarketDataCaps1
udUserDataCaps2
candle_spansсписок CandleSpan3The longest span one Candles request may cover, per timeframe, as the broker documents it. A timeframe that is not listed has no known limit. A client that reads a long history cuts it into windows of this span.

CandleSpan

ПолеТип№Описание
timeframeTimeframe1
span_nsuint642

HealthRequest

Без полей.

BotInfo

ПолеТип№Описание
namestring1
first_seen_nsint642When the gateway first heard from the bot (since the gateway started).
last_seen_nsint643
callsuint644
streamingbool5The bot has an Events stream open.
queueduint646Events waiting in the buffer of its stream.
laggeduint647How many times its stream was closed because the bot read too slowly.

HealthResponse

ПолеТип№Описание
stateGatewayState1
namestring2The name of the gateway and the broker it serves.
brokerstring3
versionstring4
epochuint645Chosen at random each time the gateway starts. A bot keeps it with its last event number.
last_sequint646The number of the last event.
detailstring7While STARTING: what the gateway is doing or what went wrong the last time.
open_ordersuint648Orders of the journal that are not known to have ended.
botsсписок BotInfo9
uptime_nsuint6410How long this run of the gateway has been up.
piduint3211The process id of the gateway.
events_totaluint6412The number of events since the start, and how many per second over the last ten seconds.
events_per_secdouble13
limitsсписок LimitInfo14How much of each bucket of the rate limit of the broker is left.
subscriptionsсписок SubscriptionInfo15The subscriptions at the broker and who holds them.

LimitInfo

One bucket of the rate limit of the broker.

ПолеТип№Описание
bucketstring1
availableuint322
capacityuint323

SubscriptionInfo

A subscription at the broker. The same request of several bots is one subscription with several owners. Only an owner can close it. The gateway’s own subscriptions (the states of orders) have the owner “(gateway)”.

ПолеТип№Описание
subuint641
whatstring2What it is: the kind and the instrument.
ownersсписок string3

EventsRequest

ПолеТип№Описание
epochuint641Where to continue. Without epoch the stream is live only.
last_sequint642The number of the last event you handled.
own_orders_onlybool3Orders and executions of the orders that this bot placed (by the journal), not those of the other bots. Everything else comes to all.

EventFrame

A frame of the Events stream. The first is always ready.

ПолеТип№Описание
readyReady1Одно из группы frame.
eventEvent2Одно из группы frame.
gapGap3Одно из группы frame.
laggedLagged4Одно из группы frame.

Ready

ПолеТип№Описание
epochuint641The epoch of this gateway run and the number the next live event will have.
next_sequint642
replayinguint643How many events follow from the ring before the live ones begin.

Gap

The events after last_seq are no longer there. Call Reconcile and read the account again: the stream goes on from now.

ПолеТип№Описание
reasonReason1
requested_afteruint642
first_availableuint643The oldest event still in the ring (the next one to come if the ring is empty).

Lagged

The stream is closed because this bot read too slowly and its buffer filled. The events in the buffer were delivered first. Reconnect with the last number you got.

ПолеТип№Описание
last_sequint641

ErrorDetail

The error of the library, whole. Sent in the brokapi-error-bin trailer of a failed call.

ПолеТип№Описание
kindKind1
codestring2REJECTED: the code of the refusal (“not_found”, “price_off_step”, …).
messagestring3CONFIG, TRANSPORT, REJECTED, GATEWAY_STARTING, BAD_REQUEST: the text.
retry_after_nsuint644RATE_LIMITED.
capabilitystring5UNSUPPORTED.

GatewayState

ЗначениеЧислоОписание
GATEWAY_STATE_UNSPECIFIED0
GATEWAY_STATE_STARTING1The gateway runs the reconcile of its journal. Every call but Health and Caps is answered UNAVAILABLE.
GATEWAY_STATE_READY2
GATEWAY_STATE_STOPPING3The gateway is stopping: no new commands.

Gap.Reason

ЗначениеЧислоОписание
REASON_UNSPECIFIED0
REASON_TOO_OLD1The ring has already dropped them (by count or by age).
REASON_NEW_EPOCH2The gateway was restarted: its numbers begin again.
REASON_AHEAD3The number is ahead of the gateway.

ErrorDetail.Kind

ЗначениеЧислоОписание
KIND_UNSPECIFIED0
KIND_CONFIG1
KIND_TRANSPORT2
KIND_RATE_LIMITED3
KIND_REJECTED4
KIND_UNKNOWN5The command may or may not have reached the broker: look at the order before anything else.
KIND_UNSUPPORTED6
KIND_NOT_RECONCILED7
KIND_DEGRADED8
KIND_SHUTTING_DOWN9
KIND_GATEWAY_STARTING10The gateway is not ready yet. The command was not run.
KIND_BAD_REQUEST11The request could not be read: a bad id, a bad number. The command was not run.

Типы: значения, заявки, портфель, рынок

Файл proto/brokapi/gateway/v1/types.proto, пакет brokapi.gateway.v1.

The types of the brokapi gateway: the same values as the types of `brokapi-core`, written for the wire.

Rules that hold for every message in this file:

  * A price, a quantity, an amount of money is a string with a decimal number ("101.25", "-0.5"). Never a double:
    a double cannot hold 0.1 and a bot that adds prices loses kopecks. Parse it into a decimal type of your language.
  * A moment of time is an integer of nanoseconds since 1970-01-01 UTC, in a field that ends with `_ns`.
  * An order id (`cid`) is a UUID in the text form with hyphens, made by the bot.
  * `optional` marks a value that may be absent: absent is not the same as an empty string or zero.

Timestamps

When the library saw something. broker_ts_ns is the broker’s own time when the broker gives one.

ПолеТип№Описание
rx_ts_nsint641

TimeRange

ПолеТип№Описание
from_nsint641
to_nsint642

InstrumentId

An instrument: the same in every broker (symbol and mic) and the way this broker names it (native). Take it from ResolveInstrument, Find or GetInstrument and pass it back as it is.

ПолеТип№Описание
symbolstring1
micstring2
nativeNativeId3

NativeId

ПолеТип№Описание
symbol_micSymbolMic1Одно из группы id.
ticker_classTickerClass2Одно из группы id.
figistring3Одно из группы id.
uidstring4Одно из группы id.

SymbolMic

ПолеТип№Описание
symbolstring1
micstring2

TickerClass

ПолеТип№Описание
tickerstring1
class_codestring2

SubscribeOpts

ПолеТип№Описание
backpressureBackpressure1
capuint642The buffer size for LOSSLESS and DROP_NEWEST.

PlaceOrderRequest

ПолеТип№Описание
cidstring1
instrumentInstrumentId2
sideSide3
order_typeOrderType4
qtystring5

ReplaceOrderRequest

ПолеТип№Описание
cidstring1The id of the new order.
original_cidstring2

OrderAck

ПолеТип№Описание
cidstring1
broker_idstring2
tsTimestamps3

OrderState

ПолеТип№Описание
kindOrderStateKind1
cidstring2
broker_idstring3ACKED.
filledstring4PARTIALLY_FILLED.
leftstring5
reasonstring6REJECTED.

OrderSnapshot

ПолеТип№Описание
cidstring1
instrumentInstrumentId3
stateOrderState4
sideSide5
order_typeOrderType6
qtystring7
filledstring8
tsTimestamps10

ReconcileReport

ПолеТип№Описание
confirmedсписок OrderSnapshot1In your ledger and active at the broker.
closed_offlineсписок string2In your ledger, not active at the broker: filled, cancelled or refused while you were away. Ask OrderState.
foreignсписок OrderSnapshot3Active at the broker, not in your ledger: somebody else’s orders. Do not touch them.

StopExpiry

ПолеТип№Описание
kindKind1
date_nsint642KIND_GOOD_TILL_DATE.

PlaceStopOrderRequest

ПолеТип№Описание
cidstring1
instrumentInstrumentId2
sideSide3
kindStopOrderKind4
qtystring5
stop_pricestring6
expiryStopExpiry8

StopOrderState

ПолеТип№Описание
kindKind1
otherstring2

StopOrderRef

A stop order by your id or by the broker’s id.

ПолеТип№Описание
cidstring1Одно из группы ref.
broker_idstring2Одно из группы ref.

StopOrderSnapshot

ПолеТип№Описание
broker_idstring2
instrumentInstrumentId3
sideSide4
kindStopOrderKind5
qtystring6
stop_pricestring7
expiryStopExpiry9
stateStopOrderState10
tsTimestamps11

BookLevel

ПолеТип№Описание
pricestring1
qtystring2

OrderBook

A full book (incremental false) or a change of it (incremental true, then seq is the number of the change).

ПолеТип№Описание
instrumentInstrumentId1
incrementalbool2
sequint643
bidsсписок BookLevel4
asksсписок BookLevel5
tsTimestamps6

MarketTrade

ПолеТип№Описание
instrumentInstrumentId1
pricestring2
qtystring3
sideSide4
tsTimestamps6

Quote

ПолеТип№Описание
instrumentInstrumentId1
tsTimestamps4

Candle

ПолеТип№Описание
instrumentInstrumentId1
timeframeTimeframe2
openstring3
highstring4
lowstring5
closestring6
volumestring7
open_ts_nsint648
close_ts_nsint649
tsTimestamps10

Balance

ПолеТип№Описание
currencystring1
availablestring2
blockedstring3
tsTimestamps4

Position

ПолеТип№Описание
instrumentInstrumentId1
qtystring2
tsTimestamps5

Portfolio

ПолеТип№Описание
balancesсписок Balance1
positionsсписок Position2
tsTimestamps3

Execution

ПолеТип№Описание
broker_order_idstring2
instrumentInstrumentId3
sideSide4
pricestring5
qtystring6
commissionstring7
trade_idstring8
tsTimestamps9

Instrument

ПолеТип№Описание
idInstrumentId1
namestring2
kindInstrumentKind4
currencystring5
exchangestring6

InstrumentQuery

ПолеТип№Описание
by_tickerByTicker1Одно из группы query.
by_isinstring2Одно из группы query.
by_kindInstrumentKind3Одно из группы query.

InstrumentQuery.ByTicker

ПолеТип№Описание
tickerstring1

TradingParams

ПолеТип№Описание
instrumentInstrumentId1
lot_sizestring2
min_qtystring3
price_stepstring4
price_step_valuestring5
currencystring6

TradingStatus

ПолеТип№Описание
instrumentInstrumentId1
availabilityTradingAvailability2

SessionInterval

ПолеТип№Описание
start_nsint641
end_nsint642
kindSessionKind3

Schedule

ПолеТип№Описание
exchangestring1
sessionsсписок SessionInterval2
tsTimestamps3

StreamingCaps

ПолеТип№Описание
order_bookbool1
market_tradesbool2
quotesbool3
candlesbool4

MarketDataCaps

ПолеТип№Описание
max_order_book_depthuint321
incremental_order_bookbool2
streamingStreamingCaps3

PlaceIdempotency

ПолеТип№Описание
kindKind1
window_secsuint642How long the broker remembers an id (the two last kinds).

UserDataCaps

ПолеТип№Описание
place_idempotencyPlaceIdempotency1
ws_rpcbool2
ordered_command_channelbool3
supports_replacebool4
supports_stop_ordersbool5
streams_executionsbool6
sandboxbool7

PositionList

ПолеТип№Описание
positionsсписок Position1

BalanceList

ПолеТип№Описание
balancesсписок Balance1

Resync

ПолеТип№Описание
subuint641
instrumentInstrumentId2
reasonResyncReason3

Overflow

ПолеТип№Описание
subuint641
lost_from_nsint642

Reconnected

ПолеТип№Описание
subuint641
gap_from_nsint642

Event

One event of the broker connection. seq counts the events of this gateway from 1, without holes, in the order the gateway got them: keep the last one you handled and give it to Events when you reconnect.

ПолеТип№Описание
sequint641
sourcestring2The connector that produced it: “NAME-md” or “NAME-ud”, NAME being the name of the gateway.
tsTimestamps4
order_bookOrderBook10Одно из группы payload.
market_tradeMarketTrade11Одно из группы payload.
quoteQuote12Одно из группы payload.
candleCandle13Одно из группы payload.
orderOrderSnapshot14Одно из группы payload. Your order changed state.
executionExecution15Одно из группы payload.
portfolioPortfolio16Одно из группы payload.
positionsPositionList17Одно из группы payload.
balancesBalanceList18Одно из группы payload.
resyncResync19Одно из группы payload. A stream of order book changes lost its place: ask for a snapshot.
overflowOverflow20Одно из группы payload. A lossless subscription of the connector overflowed. Trading stops until you call Reconcile.
reconnectedReconnected21Одно из группы payload. A stream was cut and came back: whatever happened from gap_from_ns may be missing.

Side

ЗначениеЧислоОписание
SIDE_UNSPECIFIED0
SIDE_BUY1
SIDE_SELL2

OrderType

ЗначениеЧислоОписание
ORDER_TYPE_UNSPECIFIED0
ORDER_TYPE_MARKET1
ORDER_TYPE_LIMIT2

Timeframe

ЗначениеЧислоОписание
TIMEFRAME_UNSPECIFIED0
TIMEFRAME_M11
TIMEFRAME_M52
TIMEFRAME_M103
TIMEFRAME_M154
TIMEFRAME_M305
TIMEFRAME_H16
TIMEFRAME_H47
TIMEFRAME_D18
TIMEFRAME_W19
TIMEFRAME_MN10

InstrumentKind

ЗначениеЧислоОписание
INSTRUMENT_KIND_UNSPECIFIED0
INSTRUMENT_KIND_STOCK1
INSTRUMENT_KIND_BOND2
INSTRUMENT_KIND_OPTION3
INSTRUMENT_KIND_FUTURE4
INSTRUMENT_KIND_ETF5
INSTRUMENT_KIND_MUTUAL_FUND6
INSTRUMENT_KIND_CURRENCY7
INSTRUMENT_KIND_OTHER8
INSTRUMENT_KIND_PERPETUAL9

TradingAvailability

ЗначениеЧислоОписание
TRADING_AVAILABILITY_UNSPECIFIED0
TRADING_AVAILABILITY_OPEN1
TRADING_AVAILABILITY_CLOSED2
TRADING_AVAILABILITY_BREAK3
TRADING_AVAILABILITY_UNKNOWN4

SessionKind

ЗначениеЧислоОписание
SESSION_KIND_UNSPECIFIED0
SESSION_KIND_PRE_MARKET1
SESSION_KIND_MAIN2
SESSION_KIND_POST_MARKET3
SESSION_KIND_AUCTION4
SESSION_KIND_OTHER5

ResyncReason

ЗначениеЧислоОписание
RESYNC_REASON_UNSPECIFIED0
RESYNC_REASON_SEQUENCE_GAP1
RESYNC_REASON_SUBSCRIPTION_RESET2
RESYNC_REASON_MANUAL3

StopOrderKind

ЗначениеЧислоОписание
STOP_ORDER_KIND_UNSPECIFIED0
STOP_ORDER_KIND_STOP_LOSS1
STOP_ORDER_KIND_TAKE_PROFIT2
STOP_ORDER_KIND_STOP_LIMIT3

Backpressure

ЗначениеЧислоОписание
BACKPRESSURE_UNSPECIFIED0
BACKPRESSURE_CONFLATE1The latest value replaces older ones that nobody has read yet. For prices.
BACKPRESSURE_LOSSLESS2Every value is kept up to cap. When the buffer is full the stream is marked lost and trading stops until Reconcile.
BACKPRESSURE_DROP_NEWEST3At cap the newest value is dropped.

OrderStateKind

ЗначениеЧислоОписание
ORDER_STATE_KIND_UNSPECIFIED0
ORDER_STATE_KIND_IN_FLIGHT1Sent, no answer yet.
ORDER_STATE_KIND_UNKNOWN2No answer and the outcome is not known: ask with OrderState, do not send again.
ORDER_STATE_KIND_ACKED3Accepted by the broker (broker_id).
ORDER_STATE_KIND_PARTIALLY_FILLED4Partly executed (filled, left).
ORDER_STATE_KIND_FILLED5
ORDER_STATE_KIND_CANCELLED6
ORDER_STATE_KIND_REJECTED7Refused (reason).

StopExpiry.Kind

ЗначениеЧислоОписание
KIND_UNSPECIFIED0
KIND_GOOD_TILL_CANCEL1
KIND_END_OF_DAY2
KIND_GOOD_TILL_DATE3

StopOrderState.Kind

ЗначениеЧислоОписание
KIND_UNSPECIFIED0
KIND_ACTIVE1
KIND_TRIGGERED2
KIND_CANCELLED3
KIND_EXPIRED4
KIND_OTHER5A state this version does not know: the broker’s word is in other.

PlaceIdempotency.Kind

ЗначениеЧислоОписание
KIND_UNSPECIFIED0
KIND_LABEL_ONLY1The broker only keeps the label: a second place with the same id may open a second order.
KIND_REJECT_DUPLICATE2
KIND_IDEMPOTENT3

Service: служба brokapi up и ее команды

Файл proto/brokapi/service/v1/service.proto, пакет brokapi.service.v1.

The API of the brokapi service: the commands of the program `brokapi` talk to it. The service runs the gateways of one
config file, one process each, and watches them.

It is for the person who runs the machine, not for bots: bots talk to a gateway (brokapi.gateway.v1). The service
listens on a Unix socket (or on 127.0.0.1 on Windows) in its state directory, and a call carries the key from
`service.key` of that directory in `authorization: Bearer <key>`, as a call to a gateway does.

Сервис Service

ВызовЗапросОтветОписание
InfoInfoRequestServiceInfoWhat the service is.
ListListRequestListResponseThe gateways, with what the service knows of each (the state of the process) and what the gateway says of itself. Without names: all of them.
StartGatewayRefGatewayInfoStarts a gateway that is stopped or failed. A gateway that runs is left alone.
StopStopRequestStopResponseStops a gateway and keeps it stopped until Start. With cancel_orders the active orders and stop orders of the account are cancelled first. Orders at the exchange are otherwise not touched.
RestartGatewayRefGatewayInfoStops a gateway and starts it again.
AddGatewayRefGatewayInfoReads the config file again and starts the gateway of this name from it, if it is not running.
RemoveGatewayRefGatewayInfoStops a gateway and forgets it until Add or Reload brings it back from the config.
ReloadReloadRequestReloadResponseReads the config file again and brings the running gateways in line with it: starts the new ones, stops the ones that are gone from the file, restarts the ones whose section changed.
ShutdownShutdownRequestShutdownResponseStops the service. The gateways are stopped too, unless leave_gateways is set.

InfoRequest

Без полей.

ServiceInfo

ПолеТип№Описание
piduint321
versionstring2
configstring3The config file the service was started with, and its state directory.
state_dirstring4
addressstring5Where the service listens.
started_nsuint646
uptime_nsuint647
gatewaysuint328
runninguint329

ListRequest

ПолеТип№Описание
namesсписок string1

ListResponse

ПолеТип№Описание
gatewaysсписок GatewayInfo1

GatewayRef

ПолеТип№Описание
namestring1

GatewayInfo

A gateway as the service sees it.

ПолеТип№Описание
namestring1
brokerstring2
statestring3starting, running, restarting, stopping, stopped or failed.
piduint324The process id, 0 if there is no process.
uptime_nsuint645How long the process has run.
restartsuint326How many times the service started it again after it stopped on its own.
last_errorstring7The last time it stopped on its own or could not start, and why. Empty if it never did.
restart_in_nsuint648While restarting: how long until the next start.
cpu_percentfloat9The CPU use of the process in percent of one core, and its memory in bytes.
memory_bytesuint6410
accountstring11The account and whether it is a sandbox, from the config.
sandboxbool12
adoptedbool13The service found this process running when it started, instead of starting it.
addressstring14Where the gateway listens, and its directory.
state_dirstring15

StopRequest

ПолеТип№Описание
namestring1
cancel_ordersbool2

StopResponse

ПолеТип№Описание
gatewayGatewayInfo1
cancelled_ordersuint322How many orders and stop orders were cancelled before the stop.
cancelled_stopsuint323
errorsсписок string4Orders that could not be cancelled, with the reason.

ReloadRequest

Без полей.

ReloadResponse

ПолеТип№Описание
startedсписок string1
stoppedсписок string2
restartedсписок string3
unchangedсписок string4

ShutdownRequest

ПолеТип№Описание
leave_gatewaysbool1

ShutdownResponse

Без полей.

Листать можно клавишами Влево и Вправо.

brokapi by RunInfra