Check on your resource

Check-in on what your resource has been up to

5 minute read

Resources may generate actions which are then stored on the Pocket Cloud. These actions may result in orders being sent to financial exchanges which in turn may become transactions, affecting the user’s running ledger (if not in sandbox mode).

For example, the below user resource may generate the below action, resulting in two orders with an accompanying transaction and a linked resource reward.

User
User Resource
Resource Action
Order 1
Order 2
Transaction 1
Transaction 2
Transaction 3
Resource Reward

Inspect resource records

Dependent on the type of resource, resources may output records from one or more actions. Records contain a historical record of the information a resource used to take an action. These actions can be inspected by querying the /object/record endpoint.

1
2
3
4
5
6
curl -X \
  --request GET \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/record" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"
1
2
3
4
5
6
7
curl -X \
  --no-buffer \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/record" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: text/event-stream" \
  --header "Accept: text/event-stream" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"

You should see one of the below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
	"record_id": "d96bac1d-6b68-40d7-8f20-4d9d4f2e45fb",
	"session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
	"user_id": "d6e729fa0bf5",
	"layer": ["SNAP"],
	"channel": ["NYSE American"],
	"logits": [0.561, 0.251, 0.952],
	"marked_by_soure_timestamp": [],
	"received_by_client_timestamp": [],
	"finished_by_pipeline_timestamp": [],
	"created_on_time": "2021-02-18 20:27:59.042804+00:00",
	"index": 98402018495,
	"finished_on_time": "2021-02-18 20:27:59.042824+00:00",
	"feedback_on_time": null,
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data: {"type": "begin", "timestamp": "2021-02-18T19:55:17.774130"}

data: {
  "user_id": "${USER_USER_ID}",
  "session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
  "name": "simple-manager",
  "record_id": "d96bac1d-6b68-40d7-8f20-4d9d4f2e45fb",
  "layer": ["SNAP"],
  "channel": ["NYSE American"],
  "logits": [0.561, 0.251, 0.952],
  "marked_by_source_timestamp": [],
  "received_by_client_timestamp": [],
  "finished_by_pipeline_timestamp": [],
  "created_on_time": "2021-02-18 20:27:59.042804+00:00",
  "finished_on_time": "2021-02-18 20:27:59.042824+00:00",
  "feedback_on_time": null,
  "index": [98402018495]
}

data: {...}

data: {"type": "end", "timestamp": "2021-02-18T19:55:17.774130"}
1
"You do not have access to this API"
1
"Could not find account - `account_id` not found"

When a resource takes an action, those actions are recorded under the record endpoint. For example, the above response yields actions for the SNAP ticker destined for the NYSE American exchange. These records may result in orders (below).

Inspect resource orders

Once a resource generates an action, that action may become one or more orders . Orders are submitted to either an explicitly defined exchange or an optimally chosen one. These actions may be inspected by querying the /object/order endpoint.

1
2
3
4
5
6
curl -X \
  --request GET \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/order" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"
1
2
3
4
5
6
7
curl -X \
  --no-buffer \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/order" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: text/event-stream" \
  --header "Accept: text/event-stream" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"

You should see one of the below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[
  {
    "parent_account_id": null,
    "account_id": "6ac0edf2-340b-48d4-87c1-36bcb033d7c1",
    "portfolio_id": "a6de702c-94c5-4183-a494-0a9fbe897e5c",
    "session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
    "user_parent_oid": null,
    "user_oid": "8e5e7992-1fcb-4ed5-9158-4533f35cd33c",
    "exchange_oid": "bb41-2011eb6b70dc",
    "quantity": 97.56
    "side": 1,
    "status": -3,
    "price": 345.1,
    "fees": 45,
    "timestamp": "2021-11-14T01:34:26+00:12",
    "executions": [[10, 345.12], [87.56, 345.11]]
	},
	...
]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data: {"type": "begin", "timestamp": "2021-02-18T19:55:17.774130"}

data: {
  "parent_account_id": null,
  "account_id": "6ac0edf2-340b-48d4-87c1-36bcb033d7c1",
  "portfolio_id": "a6de702c-94c5-4183-a494-0a9fbe897e5c",
  "session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
  "user_parent_oid": null,
  "user_oid": "8e5e7992-1fcb-4ed5-9158-4533f35cd33c",
  "exchange_oid": "bb41-2011eb6b70dc",
  "quantity": 97.56
  "side": 1,
  "status": -3,
  "price": 345.1,
  "fees": 45,
  "timestamp": "2021-11-14T01:34:26+00:12",
  "executions": [[10, 345.12], [87.56, 345.11]]
}

data: {...}

data: {"type": "end", "timestamp": "2021-02-18T19:55:17.774130"}
1
"You do not have access to this API"
1
"Could not find account - `account_id` not found"

Inspect resource rewards

The results of actions will output rewards , a feedback mechanism for informing the resource the status of its actions.

1
2
3
4
5
6
curl -X \
  --request GET \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/reward" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"
1
2
3
4
5
6
7
curl -X \
  --no-buffer \
  --url "https://sandbox.alpha.api.pocket-portfolio.com/object/reward" \
  --data '{"account_id": "${USER_ACCOUNT_ID}"}' \
  --header "Content-Type: text/event-stream" \
  --header "Accept: text/event-stream" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"

You should see one of the below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[
   {
    "reward_id": "2d882b36-33b8-4ea2-a49d-9b1e564fa2cc",
    "session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
    "user_id": "d6e729fa0bf5",
    "account_id": "4355bfdc-5b0c-49b8-9586-6cbff6c21f44",
    "layer": ["SNAP"],
    "channel": ["NYSE American"],
    "timestamp": "2021-11-14T01:34:26+00:12",
    "reward": 96,
  },
  ...
]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data: {"type": "begin", "timestamp": "2021-02-18T19:55:17.774130"}

data:    {
  "reward_id": "2d882b36-33b8-4ea2-a49d-9b1e564fa2cc",
  "session_id": "85aded01-2ce8-4955-947f-7030c1eb58b2",
  "user_id": "d6e729fa0bf5",
  "account_id": "4355bfdc-5b0c-49b8-9586-6cbff6c21f44",
  "layer": ["SNAP"],
  "channel": ["NYSE American"],
  "timestamp": "2021-11-14T01:34:26+00:12",
  "reward": 96,
}

data: {...}

data: {"type": "end", "timestamp": "2021-02-18T19:55:17.774130"}
1
"You do not have access to this API"
1
"Could not find account - `account_id` not found"

Resource actions will affect your portfolio and account state. Let’s inspect our linked account ledger to determine what all has occurred.

Inspect ledger state

Accounts and portfolios are linked to ledgers , a running financial statement of your resource’s actions. In free and personal mode, each account has one running ledger.

1
@TODO
1
@TODO

You should see one of the below:

1
@TODO
1
@TODO
1
"You do not have access to this API"
1
"Could not find account - `account_id` not found"

👍 Meravellós! You’ve checked-in on the state of your AI on the Pocket Cloud!

Last modified April 3, 2023: fix ubuntu issues (dc29291)