ManifoldSubscriber#

class autofold.subscriber.JobAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

ADD = 'add'#
REMOVE = 'remove'#
class autofold.subscriber.JobStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

EXECUTING = 'executing'#
FINISHED = 'finished'#
PENDING = 'pending'#
class autofold.subscriber.JobType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

INTERVAL = 'interval'#
ONEOFF = 'oneoff'#
class autofold.subscriber.ManifoldSubscriber(manifold_api: ManifoldAPI, manifold_db: ManifoldDatabase, manifold_db_writer: ManifoldDatabaseWriter)#

Bases: object

is_alive()#

Checks if the scheduler is running.

Returns:

True if scheduler is running, False otherwise.

Return type:

bool

shutdown()#
subscribe_to_all_markets(polling_time, callback)#

Continuously retrieves all (LiteMarket) markets and updates the manifold database.

Note

Only BC and MC markets right now.

Parameters:
  • polling_time (int) – Required. The number of seconds between updates.

  • callback – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

subscribe_to_all_users(polling_time, callback)#

Continuously retrieves the (LiteUser) profile of all users and updates the manifold database with it.

Parameters:
  • polling_time (int) – Required. The number of seconds between updates.

  • callback (function) – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

subscribe_to_bets(user_id, username, contract_id, contract_slug, polling_time, callback)#

Continuously retrieves bets based on a single value or a combination of the following:

  • user_id

  • username

  • contract_id

  • contract_slug

Set unused values to None.

Updates the manifold database accordingly.

Parameters:
  • user_id (str) – Optional. The ID of the user whose bets are to be retrieved.

  • username (str) – Optional. The username of the user whose bets are to be retrieved.

  • contract_id (str) – Optional. The ID of the contract (market) whose bets are to be retrieved.

  • contract_slug (str) – Optional. The URL slug of the contract (market) whose bets are to be retrieved.

  • polling_time (int) – Required. The number of seconds between each bet update.

  • callback (function) – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

subscribe_to_market(market_id, polling_time, callback)#

Continuously retrieves the (FullMarket) market for a specified market_id and updates the manifold database with the fetched data.

Note

Only BC and MC markets right now.

Parameters:
  • market_id (str) – Required. The ID of the market whose positions are to be fetched.

  • polling_time (int) – Required. The number of seconds between updates.

  • callback – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

subscribe_to_market_positions(market_id, user_id, polling_time=60, callback=None)#

Note

Due to https://github.com/manifoldmarkets/manifold/issues/2031, this function will only subscribe to the top 4000 positions by order.

Continuously retrieves the positions of a market by its market_id and updates the manifold database. Optionally tracks positions of a specific user.

Parameters:
  • market_id (str) – Required. The ID of the market to track.

  • user_id (str) – Optional. If specified, tracks the positions of this specific user in the market.

  • polling_time (int) – Required. The number of seconds between updates.

  • callback (function) – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

subscribe_to_user(user_id, polling_time, callback)#

Continuously retrieves the profile of a specified user and updates the database.

Parameters:
  • user_id (str) – Required. The ID of the user to subscribe to.

  • polling_time (int) – Required. The number of seconds between each profile update.

  • callback (function) – Required. A function to be called when the job finishes. The function should accept no arguments.

Returns:

None

unsubscribe_to_all_markets()#

Stops the continuous retrieval of all (LiteMarket) markets and removes the corresponding job from the job queue.

Returns:

None

unsubscribe_to_all_users()#

Stops the continuous retrieval of the (LiteUser) profiles of all users and updates to the manifold database.

Returns:

None

unsubscribe_to_bets(user_id, username=None, contract_id=None, contract_slug=None)#

Stops the continuous retrieval of bets based on a single value or a combination of the following:

  • user_id

  • username

  • contract_id

  • contract_slug

Set unused values to None.

Parameters:
  • user_id (str) – Optional. The ID of the user to unsubscribe from.

  • username (str) – Optional. The username of the user to unsubscribe from.

  • contract_id (str) – Optional. The ID of the contract (market) to unsubscribe from.

  • contract_slug (str) – Optional. The URL slug of the contract (market) to unsubscribe from.

Returns:

None

unsubscribe_to_market(market_id)#

Stops the subscription to a market by its market_id.

Parameters:

market_id (str) – Required. The ID of the market to stop tracking.

Returns:

None

unsubscribe_to_market_positions(market_id, user_id)#

Stops the subscription to the positions of a market by its market_id. Optionally stops tracking positions of a specific user.

Parameters:
  • market_id (str) – Required. The ID of the market to stop tracking.

  • user_id (str) – Optional. If specified, stops tracking the positions of this specific user in the market.

Returns:

None

unsubscribe_to_user(user_id)#

Stops the continuous retrieval of the profile of a specified user and removes all associated callbacks.

Parameters:

user_id (str) – Required. The ID of the user to unsubscribe from.

Returns:

None

update_all_markets()#

Retrieves information on all markets and updates the manifold database with the fetched data.

Note

This function can take roughly 45 seconds to complete given the current API speeds.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future

update_all_users()#

Retrieves the (LiteUser) profile of all users and updates the manifold database with the fetched data.

Note

This function can take roughly 5 seconds to complete given the current API speeds.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future

update_bets(user_id, username=None, contract_id=None, contract_slug=None)#

Retrieves bets based on a single value or a combination of the following:

  • user_id

  • username

  • contract_id

  • contract_slug

Updates the manifold database with the retrieved data.

Parameters:
  • user_id (str) – Optional. The ID of the user whose bets are to be retrieved.

  • username (str) – Optional. The username of the user whose bets are to be retrieved.

  • contract_id (str) – Optional. The ID of the contract (market) whose bets are to be retrieved.

  • contract_slug (str) – Optional. The URL slug of the contract (market) whose bets are to be retrieved.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future

update_market(market_id)#

Retrieves the (FullMarket) market for a specified market_id and updates the manifold database with the fetched data.

Note

Only BC and MC markets right now.

Parameters:

market_id (str) – Required. The ID of the market to be fetched.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future

update_market_positions(market_id, user_id)#

Note

Due to https://github.com/manifoldmarkets/manifold/issues/2031 this function will only retrieve the top 4000 positions by order.

Retrieves the positions of a market by its market_id and updates the manifold database with the fetched data. Optionally retrieves positions for a specific user.

Parameters:
  • market_id (str) – Required. The ID of the market whose positions are to be fetched.

  • user_id (str) – Optional. If specified, fetches positions only for this user in the specified market.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future

update_user(user_id)#

Retrieves the profile of a specified user by their user_id and updates the database with the fetched data.

Parameters:

user_id (str) – Required. The ID of the user whose profile needs to be updated.

Returns:

A Future object representing the eventual result of the API call and database update.

Return type:

Future