# Positions API

**`positions`**

This endpoint is used to return current info about your positions in **BLOOD**\
All positions in **BLOOD** are stored locally on your machine in memory (instance) and in db file (to reactivate / sell / remove on the next startup)\
**Active** positions are the one that were opened in the active blood instance (they can be active or inactive). Instances do not share active positions between them\
**Active** position is the one that is being updated once a while (depends on your position update delay) and can be sold / removed automatically by bot (strategies and remove rules)\
**Inactive** position is the one that are just stored in memory, its not being updated but you can activate it again\
**Positions in memory** are fast access, we don't need to spend time to fetch additional info, only update the existing position\
**Positions in db** are slow access, each time we want to do any action with those positions we need to refetch info (if anything changes) and then update it\
There are 3 possible variants to fetch positions

* set **`fetchMemory`** to **`true`** and **`fetchDb`** to **`false`** so the bot will return all positions that are currently stored in memory (they can be active or inactive)&#x20;
* set **`fetchMemory`** to **`false`** and **`fetchDb`** to **`true`** so the bot will return all positions that are stored in memory (it won't activate it - just refetch and update)
* set **`fetchMemory`** to **`true`** and **`fetchDb`** to **`true`** so the bot will do both things above

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media&token=c29123bd-89a9-4303-99a9-5026b48ae8ea>" path="/api/v1/quick-task/positions" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media\&token=c29123bd-89a9-4303-99a9-5026b48ae8ea)
{% endopenapi %}

**`sell`**

This endpoint is used to sell provided position by **`id`** and **`percentageToSell`**\
If the position is not found in memory the bot will automatically try to find it in db. If position is not found in both memory and db it will return an error\
If position token balance after refetching is 0 the bot will automatically remove it and return successful response\
\&#xNAN;***ATTENTION*** - **`percentageToSell`** should be an **`integer`** in **`bps format`**\
**100% = 10000**\
**10% = 1000**\
**1% = 100**&#x20;

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d>" path="/api/v1/quick-task/positions/sell" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media\&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d)
{% endopenapi %}

**`position-reactivate`**

This endpoint is used to activate position by **`id`**\
If the position is not found in memory the bot will automatically try to find it in db. If position is not found in both memory and db it will return an error\
If position token balance after refetching is 0 the bot will return error - so you should remove it by calling [#api-v1-quick-task-positions-remove](#api-v1-quick-task-positions-remove "mention") endpoint

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d>" path="/api/v1/quick-task/positions/reactivate" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media\&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d)
{% endopenapi %}

**`position-deactivate`**

This endpoint is used to activate position by **`id`**

Deactivate is only affecting positions in that are stored in memory. If position is not found the bot will still return successful response

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d>" path="/api/v1/quick-task/positions/deactivate" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media\&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d)
{% endopenapi %}

**`remove`**

This endpoint is used to remove positions by **`ids`** both from **`memory`** and **`db`**

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d>" path="/api/v1/quick-task/positions/remove" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FGYYVURGaop8KJyAmcmSQ%2Fopenapi.yaml?alt=media\&token=eb72654b-1b45-4c92-bb1a-90ca6fbe1c2d)
{% endopenapi %}

**`position-strategy-deactivate`**

This endpoint is used to disable **`position strategies`** by **`ids`**. The bot won't check for any sell triggers based on strategies but still will keep updating positions.&#x20;

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media&token=c29123bd-89a9-4303-99a9-5026b48ae8ea>" path="/api/v1/quick-task/positions/strategies/deactivate" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media\&token=c29123bd-89a9-4303-99a9-5026b48ae8ea)
{% endopenapi %}

**`position-strategy-activate`**

This endpoint is used to enable **`position strategies`** by **`ids`**

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media&token=c29123bd-89a9-4303-99a9-5026b48ae8ea>" path="/api/v1/quick-task/positions/strategies/activate" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media\&token=c29123bd-89a9-4303-99a9-5026b48ae8ea)
{% endopenapi %}

**`position-strategy-set`**

This endpoint is used to set or replace the existing **`position strategy`** by **`id`**. **`strategy`** input  should match string format as in task file. The bot won't automatically enable position strategies if disabled by default so you need to externally call [#api-v1-quick-task-positions-strategies-activate](#api-v1-quick-task-positions-strategies-activate "mention")

{% openapi src="<https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media&token=c29123bd-89a9-4303-99a9-5026b48ae8ea>" path="/api/v1/quick-task/positions/strategy" method="post" %}
[openapi.yaml](https://285536559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRWufhdF9QJ79pFmmf3JN%2Fuploads%2FQ8b3vRn3772SrSiaZkXQ%2Fopenapi.yaml?alt=media\&token=c29123bd-89a9-4303-99a9-5026b48ae8ea)
{% endopenapi %}
