Building Strategies

The user must build their strategy in the footprint of the strategy_base.Strategy class. The following methods interact with the jockbot. The user is free to build whatever signal generating functions they wish, but they must return a signals.Signal via one of the following methods. See Signals

There are methods within the JockBot that allow the user to fetch certain variables from the jockbot too.

class strategy_base.Strategy(config: strategy_base.StrategyConfig)

all strategy funcs must return a Signal object, to which you pass in an order (or list of orders) and/or a list of order_ids to cancel

for example:

def on_data(tradeable_id, player_dict)
    orders = [{'tradeable_id': tradeable_id,
             'price': 2.00
             'quantity': 1
             'side': 'buy'},
             {'tradeable_id': tradeable_id,
             'price': None
             'quantity': 1
             'side': 'sell'}]
    cancels = [
        'ord_xxx1',
        'ord_xxx2',
        'ord_xxx3'
    ]

    return Signal(orders, cancels)
Strategy.on_start(jockbot: jockbot.bot_typing.JockBot)

functions to be called upon initialization of the websockets within the JockBot.

The JockBot will pass itself through as an argument. See the JockBot documentation for available instance vars.

Parameters

jockbot – bot.JockBot

Returns

signals.Signal

Strategy.ipo_trade(jockbot: jockbot.bot_typing.JockBot) → jockbot.signals.Signal

function passes through the jockbot and should return a list of signals that will be traded during IPO

Parameters

jockbot – bot.JockBot object.

Returns

signals.Signal

Strategy.on_stop(jockbot: jockbot.bot_typing.JockBot) → jockbot.signals.Signal

functions that are called whenever the jockbot stops, such as a profit calculation.

Parameters

jockbot – bot.JockBot object

Returns

signals.Signal

Strategy.on_data(tradeable_id: str, jockbot: jockbot.bot_typing.JockBot) → jockbot.signals.Signal

The JockBot passes the following information to this function every time there is a tradeable update.

Parameters
  • tradeable_id – Tradeable ID that has been updated

  • jockbot – the bot.JockBot and all of its contained information.

The entire player dictionary for the event can be accessed, keyed by tradeable_id, structured as follows:

jockbot.player_dict[tradeable_id] = {
    'last_updated': timestamp,
    'tradeable': Tradeable object (see Jockmkt SDK docs for more)
    'count_ticks': int, the number of times this tradeable has been updated,
    'timestamp': np.ndarray[timestamp],
    'pregame_projection': pregame fpts projected, float
    'fpts_projected': np.ndarray[float] array of live fpts projected
    'fpts_scored': np.ndarray[float] of fpts scored
    'estimated': np.ndarray[float] of estimated prices
    'bid': np.ndarray[float] of bids
    'ask': np.ndarray[float] of asks
    'last': np.ndarray[float] of last traded price
    'high': np.ndarray[float] of high traded price
    'low': np.ndarray[low] of low traded price
    'stats': {
    'stat1': np.ndarray[float or int] of a stat
    the stats dict differs between sport, but contains all numerical stats for each player
    }
}
Returns

signals.Signal

Strategy.on_tick(order: jockmkt_sdk.objects.PublicOrder, public_orders: list) → jockbot.signals.Signal

The JockBot Passes information to this func every time a public order is placed.

Parameters
  • order – jockmkt_sdk.objects.PublicOrder object, the order that was placed. See jockmkt sdk docs for more.

  • public_orders – list[jockmkt_sdk.objects.PublicOrder] objects that have been placed in the event.

Returns

signals.Signal

Strategy.on_order(order: jockmkt_sdk.objects.Order, my_orders: dict[str, jockmkt_sdk.objects.Order]) → jockbot.signals.Signal

The JockBot passes the following information tot his function every time a user’s orders are updated.

Parameters
  • order – jockmkt_sdk.objects.Object object, the order that was created or updated

  • my_orders – a dictionary keyed by order_id containing orders that are active for this event

Returns

signals.Signal

Strategy.on_event(event_info: jockmkt_sdk.objects.Event) → jockbot.signals.Signal

JockBot calls this function every time the event is updated

Parameters

event_info – jockmkt_sdk.objects.Event object, see jockmkt sdk docs for info

Returns

signals.Signal

Strategy.on_play(game: jockmkt_sdk.objects.Game, games: dict[str, jockmkt_sdk.objects.Game]) → jockbot.signals.Signal

JockBot calls this function every time there is a Game update, if the user is subscribed to ‘games’

Parameters
  • game – jockmkt_sdk.objects.Game that was updated, see jockmkt sdk docs for info

  • games – list[jockmkt_sdk.objects.Game]

Returns

signals.Signal

Strategy.on_trade(trade: jockmkt_sdk.objects.Trade, public_trades: list) → jockbot.signals.Signal

Passes the trade and the list of all public trades to your strategy when there is a trade websocket message

Parameters
  • trade – jockmkt_sdk.objects.Trade

  • public_trades – list[jockmkt_sdk.objects.Trade]

Returns

signals.Signal

Fetch Player Dict with all player data

JockBot.fetch_player_dict()

Fetch a dictionary with all player informaiton, structured as follows (all arrays’ most recent update is in the last index, or -1):

player_dict =
    {tradeable_id:
        {'last_updated': time(),
        'tradeable': jockmkt_sdk.objects.Tradeable,
        'name': str,
        'count_ticks': int,
        'timestamp': numpy array of timestamps for each update,
        'pregame_projection': float,
        'fpts_projected': numpy array updated with projections,
        'fpts_scored': numpy array updated with scored fpts,
        'estimated': numpy array updated with estimated prices,
        'bid': numpy array updated with bids,
        'ask': numpy array updated with asks,
        'last': numpy array updated with last traded price,
        'high': numpy array updated with high price,
        'low': numpy array updated with low price,
        'stats': dict(stat, array of stats)}}
Returns

dict

Fetch current balance

JockBot.fetch_bal()

fetch the current balance

Returns

float, current available balance

Fetch client for use making requests

JockBot.fetch_client()

fetch the active client, for use in a Strategy class

Returns

jockmkt_sdk.client.Client

Fetch orders

JockBot.fetch_orders()

Fetch current active orders, keyed by order id. i.e. self.my_orders = { ‘ord_xxx’: jockmkt_sdk.Order }

Returns

dict[str, jockmkt_sdk.objects.Order]

Fetch Active Holdings

JockBot.fetch_holdings()

Fetch active holdings, which are stored in a dictionary as follows: self.holdings = { ‘tdbl_xxx’: jockmkt_sdk.objects.Position, ‘tdbl_xxx’: jockmkt_sdk.objects.Position }

Returns

dict[str, jockmkt_sdk.objects.Position]

Fetch Async Queue

JockBot.fetch_queue()

Returns an asyncio Queue to which messages are being pushed

Returns

asyncio.Queue

Fetch Entry

JockBot.fetch_entry()

Get the most recent entry update. It does not call the api, simply returns the last “entry” websocket message

Returns

jockmkt_sdk.objects.Entry

Fetch Games

JockBot.fetch_games()

Fetch a dictionary of games in the event

Returns

dict[str, jockmkt_sdk.object.Game]

Fetch Teams

JockBot.fetch_teams()

Fetch a dictionary of teams, keyed by team_id with a list of all players on that team

Returns

dict[team_id, list[jockmkt_sdk.objects.Entity]]