Blockhouse-app
  • Getting Started
    • SDK - File transfer
    • Trade Data Target Schema
  • Market Data Target Schema
Powered by GitBook
On this page

Market Data Target Schema

Installation

Install the SDK using pip:

pip install blockhouse==1.0.16

Sending Market Data

The send_market_data method supports sending consolidated order book data based on the Market Data schema. Below are the details of the required and optional fields for the input.

from blockhouse import MarketClient

# Initialize the client
client = MarketClient("f6d8d388f0c3c1479d5b30cb43d5346d")

# Send the market data
response = client.send_market_data(market_data)

Input Schema

The send_market_data method accepts a dictionary containing the following fields:

Field Name

Data Type

Description

Example

timestamp

str

Timestamp of the order event.

2024-07-31T20:07:25

ask_price_0

float

Ask price at level 0.

102.578125

ask_size_0

int

Ask size at level 0.

5

ask_price_1

float

Ask price at level 1.

103.578125

ask_size_1

int

Ask size at level 1.

10

ask_price_2

float

Ask price at level 2.

104.578125

ask_size_2

int

Ask size at level 2.

15

ask_price_3

float

Ask price at level 3.

105.578125

ask_size_3

int

Ask size at level 3.

20

ask_price_4

float

Ask price at level 4.

106.578125

ask_size_4

int

Ask size at level 4.

25

ask_price_5

float

Ask price at level 5.

107.578125

ask_size_5

int

Ask size at level 5.

30

ask_price_6

float

Ask price at level 6.

108.578125

ask_size_6

int

Ask size at level 6.

35

ask_price_7

float

Ask price at level 7.

109.578125

ask_size_7

int

Ask size at level 7.

40

ask_price_8

float

Ask price at level 8.

110.578125

ask_size_8

int

Ask size at level 8.

45

ask_price_9

float

Ask price at level 9.

111.578125

ask_size_9

int

Ask size at level 9.

50

bid_price_0

float

Bid price at level 0.

101.578125

bid_size_0

int

Bid size at level 0.

4

bid_price_1

float

Bid price at level 1.

100.578125

bid_size_1

int

Bid size at level 1.

8

bid_price_2

float

Bid price at level 2.

99.578125

bid_size_2

int

Bid size at level 2.

12

bid_price_3

float

Bid price at level 3.

98.578125

bid_size_3

int

Bid size at level 3.

16

bid_price_4

float

Bid price at level 4.

97.578125

bid_size_4

int

Bid size at level 4.

20

bid_price_5

float

Bid price at level 5.

96.578125

bid_size_5

int

Bid size at level 5.

24

bid_price_6

float

Bid price at level 6.

95.578125

bid_size_6

int

Bid size at level 6.

28

bid_price_7

float

Bid price at level 7.

94.578125

bid_size_7

int

Bid size at level 7.

32

bid_price_8

float

Bid price at level 8.

93.578125

bid_size_8

int

Bid size at level 8.

36

bid_price_9

float

Bid price at level 9.

92.578125

bid_size_9

int

Bid size at level 9.

40

symbol

str

Represents the security symbol.

"AAPL"


Example Usage

from blockhouse import MarketClient

# Initialize the client
client = MarketClient("f6d8d388f0c3c1479d5b30cb43d5346d")

# Define the full market data schema
market_data = {
    "timestamp_ny": "2024-07-31T20:07:25",
    "symbol": "AAPL",
    "ask_price_0": 102.578125,
    "ask_size_0": 5,
    "ask_price_1": 103.578125,
    "ask_size_1": 10,
    "ask_price_2": 104.578125,
    "ask_size_2": 15,
    "ask_price_3": 105.578125,
    "ask_size_3": 20,
    "ask_price_4": 106.578125,
    "ask_size_4": 25,
    "ask_price_5": 107.578125,
    "ask_size_5": 30,
    "ask_price_6": 108.578125,
    "ask_size_6": 35,
    "ask_price_7": 109.578125,
    "ask_size_7": 40,
    "ask_price_8": 110.578125,
    "ask_size_8": 45,
    "ask_price_9": 111.578125,
    "ask_size_9": 50,
    "bid_price_0": 101.578125,
    "bid_size_0": 4,
    "bid_price_1": 100.578125,
    "bid_size_1": 8,
    "bid_price_2": 99.578125,
    "bid_size_2": 12,
    "bid_price_3": 98.578125,
    "bid_size_3": 16,
    "bid_price_4": 97.578125,
    "bid_size_4": 20,
    "bid_price_5": 96.578125,
    "bid_size_5": 24,
    "bid_price_6": 95.578125,
    "bid_size_6": 28,
    "bid_price_7": 94.578125,
    "bid_size_7": 32,
    "bid_price_8": 93.578125,
    "bid_size_8": 36,
    "bid_price_9": 92.578125,
    "bid_size_9": 40
}

# Send the market data
response = client.send_market_data(market_data)

# Print the response
print(response)

Response Schema

The send_market_data method returns a structured response, adhering to the following schema:

Field

Data Type

Description

Example

status

str

Indicates whether the operation was successful.

"success"

message

str

Describes the status of the operation.

"Market data successfully sent."


Example Response

Successful API calls return a response similar to the following:

{
    "status": "success",
    "message": "Market data successfully sent to Blockhouse API."
}

Installation

Install the SDK using pip:

pip install blockhouse==1.0.16

Sending Market Data

The send_market_data method also supports an alternative schema with simplified fields. Below are the details of the required and optional fields.

from blockhouse import MarketClient

# Initialize the client
client = MarketClient("f6d8d388f0c3c1479d5b30cb43d5346d")

# Send the market data
response = client.send_market_data(market_data)

Input Schema

The send_market_data method accepts a dictionary containing the following fields:

Field Name

Data Type

Description

Example

timestamp_ny

str

Timestamp of the order event.

2024-07-31T20:07:25

side

str

Order side (Bid or Ask).

Bid

price

float

Market price.

102.578125

size

int

Order size.

4

symbol

str

Represents the security symbol.

10_YEAR

action

str

Specifies the type of action for the order (e.g., add, modify, or cancel).

add

order_type

str

Defines the type of order execution, such as market, limit, or stop-limit.

limit

Example Usage

from blockhouse import MarketClient

# Initialize the client
client = MarketClient("d713bb69cbdb9c15c2b30c388ebbaf6a")

# Define the full market data schema
market_data = {
    "timestamp_ny": "2024-07-31T20:07:25",
    "side": "Bid",
    "price": 102.578125,
    "size": 4,
    "symbol": "10_YEAR",
    "action": "add",
    "order_type": "limit"
}

# Send the market data
response = client.send_market_data(market_data)

# Print the response
print(response)


Response Schema

The send_market_data method returns a structured response, adhering to the following schema:

Field

Data Type

Description

Example

status

str

Indicates whether the operation was successful.

"success"

message

str

Describes the status of the operation.

"Market data successfully sent."


Example Response

Successful API calls return a response similar to the following:

{
    "status": "success",
    "message": "Market data successfully sent to Blockhouse API."
}

PreviousTrade Data Target Schema

Last updated 2 months ago