menu
Data

Persistence

DataGrids can be persisted to our APIs via our DataGrids service. This allows users to create a DataGrid and access it at a later time. Users can also share DataGrids with others so they can access your DataGrids without needing the code that created the DataGrid. This allows you to easily collaborate with your team to create grids. Persisting your DataGrids is also a necessary step to visualize DataGrids on our Marquee Markets platform.

Persist Your DataGrid

If you already have a DataGrid created in GS Quant, you can create, update, and share the grid.

Below are the methods used for persisting DataGrids:

MethodDescription
createCreates a new DataGrid whether or not the DataGrid has previously been persisted. Also useful for copying an existing datagrid to start a new one.
saveCreates or updates the DataGrid if it already exists. If you already have this DataGrid in a workspace the changes will be available on page refresh.
deleteDeletes the DataGrid if it has been persisted.

More can be found about these functions below with examples.

Create a Persisted DataGrid

The create method on a DataGrid will create a new DataGrid. The function returns the unique identifier of the newly created DataGrid. The DataGrid can from now on be referenced from this id.

datagrid_id = datagrid.create()
print(datagrid_id)

Output:

DGAMPVEIQVPFKW4S2Q

Update a Persisted DataGrid

You may not want to always want to create a new DataGrid everytime you wish to update a grid. In this case, users should use the save method. This also allows you to improve and add functionaltiy to your DataGrid over time.

datagrid_id = datagrid.save()
print(datagrid_id)

Output:

DGAMPVEIQVPFKW4S2Q

The create method will update the DataGrid if it has already been created and persisted. If the grid has not been persisted before, it will be created automatically. Users can see if a datagrid has already been persisted if it has an id. Users can check if the grid has an id by doing:

datagrid_id = datagrid.get_id()

If the DataGrid id is not None, then the DataGrid has already been persisted.

Share a Persisted DataGrid

Sharing a DataGrid can be done by editting the entitlements of a DataGrid.

This can be accomplished at the instantiation of the DataGrid object or updated anytime afterwards. Here's an example of both cases (we assume you have a rows and columns variables, see the overview to learn how to create these):

from gs_quant.api.gs.users import GsUsersApi

my_guid = GsUsersApi.get_my_guid()

entitlements = {
  'view': [my_guid],
  'edit': [my_guid],
  'admin': [my_guid]
}

datagrid = DataGrid('My DataGrid', rows=rows, columns=columns, entitlements=entitlements)
datagrid.save() # Persist/Create your datagrid with only you having access

# Add your friends to the view entitlements
emails = ['your@email.com', 'friends@email.com', 'emails@email.com', 'here@email.com']
my_friends_guids = GsUsersApi.get_guids_from_ids(GsUsersApi.get_user_ids_by_email(emails))
datagrid.entitlements['view'].extend(my_friends_guids)
datagrid.save() # Update your datagrid with your friends whom now have view access
info

Note

By default, every DataGrid you create is just entitled to yourself for each entitlement type unless you update or pass in entitlements.

Entitlements

Let us break down what each of these entitlements entail.

Entitlement TypeDescription
viewEntitled users can access the DataGrid.
editEntitled users can edit everything on the DataGrid except entitlements.
adminEntitled users can edit everything on the DataGrid including entitlements.

Delete a Persisted DataGrid

In some cases, users may want to delete a persisted DataGrid. This can be done by:

datagrid_id = datagrid.delete()

The delete method will remove the DataGrid from our APIs, hence all users who had access also cannot access it. Be careful when deleting DataGrids if others are using them!

Get Your Persisted DataGrids

Utilizing the GsDataGridApi class, users can get their all the DataGrids that they are entitled to view.

Get Many DataGrids

from gs_quant.api.gs.datagrid import GsDataGridApi

datagrids = GsDataGridApi.get_datagrids()
datagrid = datagrid[0]

# Then you can calculate your grids
datagrid.initialze(), datagrid.poll()
datagrid.to_frame()

By default, the method gets the first 10 DataGrids ordered by recently updated grids, but this limit can be increased by passing the limit argument. Users can also get just the DataGrids that they have created.

Get Your Own DataGrids

Users can get just the DataGrids they have created.

from gs_quant.api.gs.datagrid import GsDataGridApi

datagrids = GsDataGridApi.get_my_datagrids()

Get a Specific DataGrid

Users can get a single DataGrid by using the DataGrid id of the grid you want.

from gs_quant.api.gs.datagrid import GsDataGridApi

datagrid = GsDataGridApi.get_datagrid('DGAMPVEIQVPFKW4S2Q')

help

Questions?

Please contact us at gs-marquee-markets@gs.com with any questions or feedback.


Related Content