Manage your Watchlists¶
Watchlists are an essential feature in Bigdata, allowing users to track specific securities or assets of interest with ease. Below, we’ll walk you through the process of managing your watchlists.
Create a Watchlist¶
To create a new watchlist, use the create
method and define the name and a list of items:
from bigdata_client import Bigdata
from bigdata_client.query import Watchlist
bigdata = Bigdata()
# Entity IDs:
META = "12E454"
AMAZON = "0157B1"
MICROSOFT = "228D42"
APPLE = "D8442A"
ALPHABET = "4A6F00"
MAMAA_watchlist = bigdata.watchlists.create(name="MAMAA stocks news", items=[META, AMAZON, MICROSOFT, APPLE, ALPHABET])
print(MAMAA_watchlist)
Output:
id='b548fc37-87d3-4bc7-b482-eeeeb7060f78' name='MAMAA stocks news' date_created=datetime.datetime(2024, 9, 18, 14, 45, 23, 659778) last_updated=datetime.datetime(2024, 9, 18, 14, 45, 23, 659831) query_type='watchlist' company_shared_permission=None
Retrieve Watchlists¶
You can retrieve a watchlist by ID using the method get
:
my_watchlist = bigdata.watchlists.get(MAMAA_watchlist.id) # for instance: "b548fc37-87d3-4bc7-b482-eeeeb7060f78"
print(my_watchlist)
Output:
id='b548fc37-87d3-4bc7-b482-eeeeb7060f78' name='MAMAA stocks news' date_created=datetime.datetime(2024, 9, 18, 14, 45, 23, 659778) last_updated=datetime.datetime(2024, 9, 18, 14, 45, 23, 659831) query_type='watchlist' company_shared_permission=None
The retrieved watchlist object contains the id
, name
and metadata such as date_created
or last_updated
, representing the dates when the object was created and last updated, respectively.
And you can access the watchlist items
list from the object (Items are lazy evaluated)
print(my_watchlist.items)
Output:
['0157B1', 'D8442A', '4A6F00', '12E454', '228D42']
You can also retrieve all your watchlists with the method list
:
all_watchlists = bigdata.watchlists.list()
Caution
When fetching all watchlists (bigdata.watchlists.list()
) you will get all the watchlists you have access to, that is, those that belong to you and those that were shared from someone within your organization.
list
method support owned
parameter
When owned=True
is provided only watchlists which owned by logged user will be returned
owned_watchlists = bigdata.watchlists.list(owned=True)
Update Watchlists¶
Once you define a watchlist, you can always update its name:
my_watchlist.name = "MAMAA Product Release"
my_watchlist.save()
Extend the list of existing items:
my_watchlist.items.append("business,products-services,product-release,,")
my_watchlist.save()
Or entirely replace it:
my_watchlist.items = ["<new_list>"]
my_watchlist.save()
Delete Watchlists¶
If you no longer need a watchlist, you can delete it using the delete
method.
Using the object in memory:
my_watchlist.delete()
Or using its ID:
bigdata.watchlists.delete("<the_watchlist_id>")