Events

Gravity's streaming service provides real-time and replayable event streams through Server-Sent Events (SSE), offering a robust solution for delivering updates directly to your applications. With SSE, you can seamlessly subscribe to various event types such as—orders, transfers, and customer data—and receive instant updates as they occur. This ensures that your application stays responsive and your users are always informed.

Using Gravity's SSE Streaming Service

  • Real-Time Updates: Receive immediate notifications for critical events, allowing for prompt and informed decision-making.
  • Efficient Resource Usage: Maintain a single, persistent connection to stream multiple updates, minimizing resource consumption on both client and server sides.
  • Easy Integration: Implementing SSE requires minimal setup, and our service integrates smoothly with existing systems, providing an easy-to-use alternative to more complex protocols like WebSockets.

Key Features

  • Token-Based Authentication: Secure your connections with token-based authentication, ensuring that only authorized clients can access the event streams.
  • Event Filtering: Streamline your data consumption by filtering events based on firm-specific IDs, ensuring that you only receive the data relevant to your organization.
  • Customizable Event Types: Subscribe to specific event types such as orders, transfers, or customers, allowing you to focus on the data that matters most to your business.

Best Practices

  • Connection Health: Implement heartbeat checks to maintain connection stability and detect any potential issues early.
  • Error Recovery: Ensure that your client application is prepared for disconnections by implementing automatic reconnection logic to maintain continuous event streaming.
  • Selective Listening: Tailor your subscriptions to focus on the most relevant event types for your use case, reducing unnecessary data processing and improving overall efficiency.

By leveraging Gravity's SSE streaming service, you can build a more responsive, resource-efficient, and easily manageable solution for real-time data updates, ensuring that your application provides a seamless user experience.


GET/v1/events/orders

Get Order Events

Use this endpoint to retrieve real-time order events via Server-Sent Events (SSE). This connection will provide continuous updates as orders are processed and new events are generated.

Success Response

JSON
200 OK
{
    "event": "order",
    "id": 4,
    "data": {
    "customerId": "46699f8e-4003-42f2-b0cc-bb064cc27d1e",
    "type": "MARKET",
    "quantity": 2,
    "side": "SELL",
    "solicited": false,
    "symbol": "META",
    "timeInForce": "DAY",
    "portfolioId": "869b7b4a-83c5-4444-8496-fcffc947a4c4",
    "status": "ACTIVE",
    "message": "Order routed",
    "reservedAmount": 0,
    "correspondentId": "a3884657-e519-4d5e-b1e6-e2551ebe708e",
    "firmId": "acf4d766-f99d-408d-8450-888d208188de",
    "commission": 2.99,
    "averageFilledPrice": null,
    "limitPrice": null,
    "createdAt": "2024-08-14T21:42:48.600Z",
    "updatedAt": "2024-08-14T21:42:48.600Z",
    "orderId": "21ab6fe7-66c9-41f0-8615-5e9c26c9035a"
}
}

GET/v1/events/transfers

Get Transfer Events

Use this endpoint to retrieve real-time transfer events via Server-Sent Events (SSE). This connection will provide continuous updates as transfers are processed and new events are generated.

Success Response

JSON
200 OK
{
    "event": "transfer",
    "id": 3,
    "data": {
    "customerId": "46699f8e-4003-42f2-b0cc-bb064cc27d1e",
    "type": "DEPOSIT",
    "amount": 249.94,
    "sourceId": "1a248e13-e908-4756-8882-db98fda32cca",
    "portfolioId": "869b7b4a-83c5-4444-8496-fcffc947a4c4",
    "status": "COMPLETED",
    "correspondentId": "a3884657-e519-4d5e-b1e6-e2551ebe708e",
    "firmId": "acf4d766-f99d-408d-8450-888d208188de",
    "message": "Transfer completed successfully",
    "clearedAt": "2024-08-19T00:26:10.866Z",
    "createdAt": "2024-08-15T00:26:10.674Z",
    "updatedAt": "2024-08-15T00:26:10.674Z",
    "transferId": "aec711b5-b463-4b70-a6c6-2d4297f8a3d3",
    "holdPeriod": 4
}
}

GET/v1/events/customers

Get Customer Events

Use this endpoint to retrieve real-time customer events via Server-Sent Events (SSE). This connection will provide continuous updates as customer data is updated and new events are generated.

Success Response

JSON
200 OK
{
    "event": "customer",
    "id": 2,
    "data": {
    "customerId": "12c63b0f-05fa-4509-97d4-ae5d3a9c1f41",
    "correspondentId": "a3884657-e519-4d5e-b1e6-e2551ebe708e",
    "accountNumber": "D9832BBBF",
    "accountType": "IRA",
    "portfolioType": "MARGIN",
    "registeredRepReview": {
    "registeredRepName": "Alice Rep",
    "registeredRepId": "c75b1b92-fdc8-47ca-bd70-c57c0efa38df",
    "outcome": "REVIEW"
},
    "dateOfBirth": "1962-05-06",
    "email": "tvX3I526@hotmail.com",
    "firstName": "Alice",
    "lastName": "Brown",
    "maritalStatus": "MARRIED",
    "middleName": "A",
    "phoneNumber": "+16218954343",
    "homeAddress": {
    "line1": "863 Highland Rd",
    "city": "Ridgefield",
    "state": "CA",
    "postalCode": "15568",
    "line2": null
},
    "mailingAddress": {
    "line1": "613 Cedar St",
    "city": "Salem",
    "state": "MI",
    "postalCode": "82694",
    "line2": null
},
    "citizenshipCountry": "USA",
    "taxResidencyCountry": "USA",
    "taxId": "617721024",
    "taxIdType": "USA_SSN",
    "disclosures": {
    "politicallyExposedPerson": false,
    "publicCompanyControlPerson": false,
    "associatedPerson": false,
    "correspondentEmployee": null,
    "publicCompanySymbol": null,
    "associatedPersonEmployer": null,
    "sendDuplicateStatements": null,
    "sendDuplicateConfirmations": null,
    "sendDuplicateStatementsEmails": null,
    "sendDuplicateConfirmationsEmails": null
},
    "employment": {
    "status": "EMPLOYED",
    "employer": "Beta Corp",
    "employerAddress": {
    "line1": "714 Cedar St",
    "city": "Kingston",
    "state": "IL",
    "postalCode": "25514",
    "line2": null
}
},
    "investmentProfile": {
    "annualIncome": 241512,
    "investmentHorizonYears": "SHORT",
    "investmentObjectives": "INCOME",
    "liquidNetWorth": 300295,
    "liquidityNeeds": "NOT_IMPORTANT",
    "netWorth": 597791,
    "optionTransactionsPerYear": 69,
    "riskTolerance": "MODERATE",
    "stockTransactionsPerYear": 95,
    "federalTaxRate": 45,
    "optionsTradingExperience": "EXTENSIVE",
    "stockTradingExperience": "LIMITED"
},
    "trustedContact": {
    "email": "1XNYHUXM@example.com",
    "firstName": "Mike",
    "lastName": "Wilson",
    "middleName": "A",
    "phoneNumber": "+14495171812"
},
    "backupWithholding": false,
    "gravityIdentityCheck": true,
    "ipAddress": "167.138.188.73",
    "groupId": "",
    "status": "APPROVED",
    "message": "Account approved",
    "frozen": false,
    "group": {
    "createdAt": "2024-05-22T17:45:30.927Z",
    "updatedAt": "2024-05-22T17:45:30.927Z",
    "groupId": "80c76dba-3c50-4df9-ac42-c415371d0b06",
    "groupName": "default"
},
    "createdAt": "2024-08-19T00:59:19.828Z",
    "updatedAt": "2024-08-19T00:59:19.828Z"
}
}

GET/v1/events/journals

Get Journal Events

Use this endpoint to retrieve real-time journal events via Server-Sent Events (SSE). This connection will provide continuous updates as journal entries are processed and new events are generated.

Success Response

JSON
200 OK
{
    "event": "journal",
    "id": 1,
    "data": {
    "createdAt": "2024-08-30T01:13:47.653Z",
    "updatedAt": "2024-08-30T01:13:47.653Z",
    "journalId": "0c3e3c83-305b-4067-90fe-8c8bfb1df7dc",
    "correspondentId": "a3884657-e519-4d5e-b1e6-e2551ebe708e",
    "firmId": "acf4d766-f99d-408d-8450-888d208188de",
    "portfolioId": "0bea7102-5c7e-4bd0-9305-0f0364e4329a",
    "customerId": "6acbbf7c-0674-4c98-9e4d-c24a0f5e1924",
    "amount": 250,
    "direction": "RECEIVED",
    "symbol": null,
    "quantity": null,
    "entryType": "CASH",
    "currency": null,
    "description": "Birthday gift",
    "status": "CREATED"
}
}