This the multi-page printable view of this section. Click here to print.
Documentation
- 1: Overview
- 2: Tutorials
- 2.1: Getting Started
- 2.1.1: Create a new user
- 2.1.2: Access the user account
- 2.1.3: Verify the user entity
- 2.1.4: Fund your account
- 2.1.5: Create a portfolio
- 2.1.6: Deploy a resource
- 2.1.7: Check on your resource
- 2.1.8:
- 3: Concepts
- 4: API Reference
- 4.1: OpenAPI 2.0
- 5: Pricing
1 - Overview
Pocket Gateway
and its capabilites.This is a placeholder page that shows you how to use this template site.
The Overview is where your users find out about your project. Depending on the size of your docset, you can have a separate overview page (like this one) or put your overview contents in the Documentation landing page (like in the Docsy User Guide).
Try answering these questions for your user in this page:
What’s the Pocket Gateway
?
@TODO
What can I do with this API?
@TODO
How do I get started?
@TODO
- Getting Started: Get started with the
Pocket Gateway
2 - Tutorials
Pocket Gateway
.This section of the Pocket Gateway
documentation contains tutorials. A tutorial shows how to accomplish a goal that is larger than a single task. Typically a tutorial has several sections, each of which has a sequence of steps.
2.1 - Getting Started
Pocket Gateway
In less than <15 minutes you’ll be able to deploy a fully personalized investment manager investing and trading directly on your or your customer’s behalf!
Learning Outcomes
💪 Afterwards, you’ll be able to:
2.1.1 - Create a new user
Pocket Gateway
Create a new user
First, you will need to create a new user and an accompanying account.
Only free and personal accounts are supported!
Onlyfree
and personal
accounts are currently supported. professional
and bespoke
plans are not yet available.
Replace the environment variables with your given and family name, email, and temporary password.
You will be asked to change the password once the user identifies themselves.
|
|
|
|
If your user was created successfully, you should see:
|
|
|
|
-
Make note of the
user_id
, you will need it later! -
free
andpersonal
accounts will automatically create a linked account.
Generate an access token
We’re now going to generate a JWT to authenticate with
the Pocket Gateway
.
|
|
|
|
You should get a response containing the token in the access_token
attribute.
|
|
|
|
Not the most secure option!
This method of generating an access token is not the most secure. We use it here for illustrative purposes; rather if you’re building an application or requesting an access token often, prefer theobject/token/oauth
access flow.
👍 Wonderful! You’ve created a new user on the Pocket Cloud and now have an access token to start deploying resources!
2.1.2 - Access the user account
Access user account
- If you are creating
professional
orbespoke
accounts, you will have to create the accounts manually.
First, let’s get all accounts associated to the user:
|
|
|
|
You should receive an array populated with universally unique identifiers (RFC 4122 complaint) to the user accounts.
|
|
|
|
Check account status:
|
|
|
|
You should see two accounts; the first account is the production account as indicated with the is_sandbox=false
flag–which you’ll be billed for, and the second account is the sandbox account, which you can use as an isolated, non-billable environment to test different resources (AIs).
|
|
|
|
Account is not yet verified!
You may notice that the accountis_verified
is still in the false
state. Most Pocket endpoints will be unavailable until the user has completed verification. At which point, once the user’s identity is verified, the account will be marked true
.
Get account details:
|
|
|
|
You should get the below:
|
|
|
|
👍 Báječné! You’ve accessed your newly created account on the Pocket Cloud
!
2.1.3 - Verify the user entity
Verify user entity
Before you can deploy most resources, you will have to verify the calling user entity. In most circumstances, all you’ll need to do is provide a government issued ID and verify your proof of identity.
- For some account types such as
professional
andbespoke
, you will need to provide additional information.
graph LR
L[Legal Entity] --> U1[User 1]
U1[User 1] --> A1[Main Account]
U1[User 1] --> A2[Sandbox Account]
L[Legal Entity] --> Verification{Is verified?}
Verification{Is verified?} --> Access([Resource Access])
Kick-off verification
To start the verification process, send a POST
request to the object/entity
endpoint.
@TODO
Check verification status
Once the verification has been completed, you can check the status of user accounts by querying the object/account
endpoint. Now, you should see that the user account has been verified.
@TODO
👍 Wunderbar! You’ve verified your entity on the Pocket Cloud
!
2.1.4 - Fund your account
@TODO
2.1.5 - Create a portfolio
Create a portfolio
Before you can start deploying resources onto the Pocket Cloud
, you must create a financial portfolio that is linked to your account.
@TODO
2.1.6 - Deploy a resource
Pocket Gateway
We’re now going to deploy a resource–an artificial intelligence, on the Pocket Cloud
.
A resource is a set of one or more trained policies which carry out a set of pre-defined tasks. In other words, a resource is an “AI” that performs actions on behalf of the calling user.
Resources are identified by a family
and name
. Resources within the same family are logically related. Once a resource is deployed on the Pocket Cloud
It is assigned an id , a universally unique RFC 4122
complaint identifier.
Employ a resource
For this example, we’ll be using the simple-manager
resource which constructs a random financial portfolio. This resource is always used in sandbox mode so you don’t need to worry about incurring billing charges.
We’re going to employ a resource with a few configurable parameters.
Resource families
have different configurable parameters.
|
|
Variable | Description | |
---|---|---|
USER_RESOURCE_SECTOR |
One or more financial sectors to which the resource is being deployed to | |
USER_RESOURCE_EXCHANGE |
A specific financial exchange the resource will read data from and submit orders to | |
USER_RESOURCE_PRODUCT |
An array of products(tickers/symbols) to be used | |
USER_RESOURCE_ALLOCATION |
A percentage of the user’s account size to be allocated to the resource; i.e., “allocate 20% of my account size to this portfolio manager.” | |
USER_RESOURCE_CONFIG_FREQUENCY |
How frequently the resource can take actions; e.g., rebalance, adjust positions, place and cancel orders. | |
USER_RESOURCE_CONFIG_MAX_SIZE |
The largest possible order size that the resource may submit. |
-
Note: the resource’s balance may increase or decrease in percentage terms as it relates to the original account balance. As a result, you may experience significant “drift” from the original percentage allocation to the current time’s present allocation.
-
Note: the more frequent the data, the more potential actions, and the more potential trading costs.
-
Note: observe that a resource may place multiple orders over sequential time-steps resulting in a “total lot size” greater than
max_size
|
|
|
|
After employing the resource, you should receive a status message:
|
|
|
|
Verify resource status
To check on the status of the resource, query the /resource/ping
endpoint
|
|
|
|
|
|
|
|
Retire a resource
You’ll probably want to shutdown your resource after awhile. Let’s send a POST
request to the resource/retire
endpoint and teardown our running resource.
- You’ll need the
USER_RESOURCE_ID
environment variable from above.
|
|
|
|
You should then see something like the below. (it may take a moment for the resource to properly cleanup and shutdown)
|
|
|
|
👍 Zvinoshamisa! You’ve employed and retired your first AI onto the Pocket Cloud
!
2.1.7 - Check on your resource
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.
graph LR
U[User] --> UR([User Resource])
UR([User Resource]) --> RA[Resource Action]
RA[Resource Action] --> O1[Order 1]
RA[Resource Action] --> O2[Order 2]
O1[Order 1] --> T11[Transaction 1]
O2[Order 2] --> T21[Transaction 2]
O2[Order 2] --> T22[Transaction 3]
RA[Resource Action] --> RR([Resource Reward])
Use SSE to receive up-to-date information from your resources
- All of the below endpoints alternatively support the SSE protocol. You may open a long-lived session to the
Pocket Cloud
by passing theAccept: text/event-stream
header to your HTTPs request. All other parameters remain the same.
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.
|
|
|
|
You should see one of the below:
|
|
|
|
|
|
|
|
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.
|
|
|
|
You should see one of the below:
|
|
|
|
|
|
|
|
Inspect resource rewards
The results of actions
will output rewards
, a feedback mechanism for informing the resource the status of its actions.
|
|
|
|
You should see one of the below:
|
|
|
|
|
|
|
|
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.
|
|
|
|
You should see one of the below:
|
|
|
|
|
|
|
|
👍 Meravellós! You’ve checked-in on the state of your AI on the Pocket Cloud
!
2.1.8 -
3 - Concepts
Pocket Gateway
, helping you develop a deeper understanding of the Pocket
ecosystem.4 - API Reference
4.1 - OpenAPI 2.0
5 - Pricing
Pocket Gateway