API Client

class traderion.client.TraderionClient(username, password, room_id)

Main API interface.

On instantiation, the client will authenticate with the provided credentials and will fetch the initial room data.

Parameters:
  • username (str) -- traderion username
  • password (str) -- traderion password
  • room_id (int) -- id of the current playing room
Raises:
  • LoginError -- if the credentials are not correct
  • RoomNotFound -- if the room is is not correct
accept_client_call(call_id)

API call to accept a client call.

Note: the client call must not have client_price set to None

Parameters:

call_id (int) -- call id

Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_dark_pool_order(direction, amount, price)

Coroutine. API call to place an order in dark pool.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • order_type (int) -- 0/1 (LIMIT/MARKET)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_foc(direction, amount, price)

Coroutine. API call to add a "fill or kill" order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_iceberg(direction, amount, price, chunk)

Coroutine. API call to add an iceberg order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
  • chunk (int) -- order chunk
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_iceberg_plus(direction, amount, price, chunk)

Coroutine. API call to add an iceberg plus order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
  • chunk (int) -- order chunk
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_ioc(direction, amount, price)

Coroutine. API call to add an "immediate or cancel" order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_limit_order(direction, amount, price)

Coroutine. API call to add a limit order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_limit_plus(direction, amount, price, chunk)

Coroutine. API call to add a "limit plus" order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_market_order(direction, amount, price)

Coroutine. API call to add a market order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
add_order(direction, amount, price, **kwargs)

Coroutine. API call to add an order in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to add
  • amount (int) -- order amount (short amount)
  • price (float) -- order price
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
cancel_all_orders()

API call to cancel all own orders.

Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
cancel_order(order_id)

API call to cancel an order.

Parameters:

order_id (int) -- order id

Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
decline_client_call(call_id)

API call to decline a client call.

Note: the client call must not have client_price set to None

Parameters:

call_id (int) -- call id

Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
get_client_calls()
Returns:an array with active client calls
Return type:list
Client Call:

id: call id

client: name of the client

date: call date

amount: call amount (short amount)

direction: 0/1 (BID/ASK, client buys/client sells)

is_hedging: whether the client is a hedge fund or not

is_binding: whether there is a binding contract with the client or not

max_spread: the maximum spread you can quote to the client (None if is_binding is False)

client_price: the price at which the client wants to buy or sell (None if the client requests quote)

trader_quote: the quote offered by the trader (None if client_price is not None or the trader hasn't quoted yet)

get_eb_depth()
Returns:an object with the depth of the market on both sides (BID/ASK)
Return type:dict

Example: {

0: [{'amount': 10, 'count': 1, 'price': 4.2340}, ...],

1: [{'amount': 10, 'count': 1, 'price': 4.2350}, ...]

}

Each entry in the eb depth has three attributes:

price: the price of the orders

amount: the total amount of the orders with that price (short amount)

count: the total number of orders with that price

get_market_prices()
Returns:an object with the market prices (as float)
Return type:dict
Market prices:

bid: the current market bid

ask: the current market ask

open: the open price of the scenario

get_orders()
Returns:an array of electronic broker orders
Return type:list
EB Order:

id: order id

amount: order amount (short amount)

direction: 0/1 (= BID/ASK)

price: order price

date: date added

get_position()
Returns:an object with all the info about your current position
Return type:dict
Position properties:

amount: full amount of the position

rate: average rate of the position

pnl: the PnL expressed in the reporting currency of the swift

converted_pnl: the PnL expressed in USD

pnl_percentage: the PnL relative to the position limit

return_on_volume: the PnL relative to the total traded volume

limit: position limit (full amount)

mat: management action trigger (1% of the position limit)

risk: the absolute amount over the position limit

limit_utilization: (percent) position amount from position limit

headroom: the available amount to trade before the position limit is broken

get_price_curve()
Returns:an array of market prices represented as (date, price) tuples
Return type:list
get_room_parameters()
Returns:an object with the room parameters
Return type:dict
Room parameters:

asset_class: the name of the asset class (ex: FX, EQ, FI)

swift: the name of the swift (ex: EUR/USD, TSLA, US10Y)

min_ticket: the minimum dealing ticket (in short amount, ex: 1 for FX)

max_ticket: the maximum dealing ticket (in short amount, ex: 10 for FX)

price_decimals: the number of decimals in a quotation (ex: 4 for FX, 2 for EQ)

ticket_unit: the full amount of a ticket of value 1 (ex: 1000000 for FX, 1 for EQ, 1000000 for FI)

hit_price(direction, amount, price)

API call to hit a price in electronic broker.

Parameters:
  • direction (int) -- 0/1 (BID/ASK) direction to hit
  • amount (int) -- hit amount (short amount)
  • price (float) -- the price to hit
Returns:

server response, an object with {'amount': the amount that was actually hit (short amount)}

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints
is_finished

Property

Returns:True if the room is finished, False otherwise
Return type:bool
is_paused

Property

Returns:True if the room is paused, False otherwise
Return type:bool
is_playing

Property

Returns:True if the room is playing, False otherwise
Return type:bool
quote_client_call(call_id, quote)

API call to answer a client call.

Note: the client call must have client_price set to None

Parameters:
  • call_id (int) -- call id
  • quote (float) -- the price offered to the client
Returns:

server response (nothing important for this action)

Return type:

dict

Raises:
  • ServerError -- if there is an internal server error
  • ValidationError -- if there is an issue with the payload
  • TradingError -- if the action cannot be completed because of other trading constraints