Trading Bot

class traderion.bot.TraderionBot(username, password, room_id, loop_sleep=1)

Base class to create a custom trading bot.

On instantiation it will create a traderion.client.TraderionClient with the provided credentials and will store it in a member called api. Through this member you will call the API methods.

Parameters:
  • username (str) -- traderion username
  • password (str) -- traderion password
  • room_id (int) -- id of the current playing room
  • loop_sleep (float) -- the frequency (in seconds) of the main loop, defaults to 1
log_info()

Implement this method if you want to log something to the console.

The method will run in a separate thread, so you can use an infinite loop here.

Check the example for more details.

main_loop()

Implement this method to add your custom bot logic.

This method will run every loop_sleep seconds while the room is playing.

Check the example for more details.

on_client_deal(client_call)

Implement this callback to receive notifications when a client deal is done.

See traderion.client.TraderionClient.get_client_calls() to see the object's structure.

Parameters:client_call -- the accepted client call
on_client_reject(client_call)

Implement this callback to receive notifications when a client deal is rejected.

See traderion.client.TraderionClient.get_client_calls() to see the object's structure.

Parameters:client_call -- the declined client call
on_eb_depth_change(old_depth, new_depth)

Implement this callback to receive notifications when the eb depth changes.

See traderion.client.TraderionClient.get_eb_depth() to see the object's structure.

Parameters:
  • old_depth -- old state of the eb depth
  • new_depth -- new state of the eb depth
on_market_price_change(old_prices, new_prices)

Implement this callback to receive notifications when the market prices change.

See traderion.client.TraderionClient.get_market_prices() to see the object's structure.

Parameters:
  • old_prices -- old state of the prices
  • new_prices -- new state of the prices
Returns:

on_new_client_call(client_call)

Implement this callback to receive notifications when a new client call is available.

Note: if the client_price attribute in the client_call is None, then the client needs a quote, otherwise you have to either accept or decline the call.

See traderion.client.TraderionClient.get_client_calls() to see the object's structure.

Parameters:client_call -- the new client call
on_orders_change(old_orders, new_orders)

Implement this callback to receive notifications when the eb orders change.

See traderion.client.TraderionClient.get_orders() to see the object's structure.

Parameters:
  • old_orders -- old state of the eb orders
  • new_orders -- new state of the eb orders
on_position_change(old_position, new_position)

Implement this callback to receive notifications when position changes.

See traderion.client.TraderionClient.get_position() to see the object's structure.

Parameters:
  • old_position -- old state of the position
  • new_position -- new state of the position
on_price_curve_change(old_price_curve, new_price_curve)

Implement this callback to receive notifications when the price curve changes.

See traderion.client.TraderionClient.get_price_curve() to see the object's structure.

Parameters:
  • old_price_curve -- old state of the price curve
  • new_price_curve -- new state of the price curve
on_room_status_change(old_status, new_status)

Implement this callback to receive notifications when the room status changes.

The possible values are: 'playing', 'paused', 'finished'.

Parameters:
  • old_status -- old room status
  • new_status -- new room status
run()

You should not override this method.

This method calls main_loop every loop_sleep seconds while the room is playing.

Call this method in your main function to start the bot. Check the example for more details.