# 为资产自定义价格源

{% hint style="info" %}
解决的问题

在 Elven 中，记账、计算公允价值等环节都会使用到资产的价格，一般情况下，Elven 使用 [Coingecko](https://www.coingecko.com/) 的价格作为加密资产的默认价格源，使用 [Exchangerates](https://exchangeratesapi.io/) 作为法币的默认汇率价格源。

用户也可以不使用 Elven 默认的价格源，改用其他的价格，例如从交易所导出的价格明细，或者单独维护的价格信息等，这些需求可以通过自定义价格源功能来实现。
{% endhint %}

## 使用步骤

在估值模块中，通过导航中的“价格”进入价格源列表，可以看到目前系统中已经在使用的价格源。

Coingecho 是 Elven 默认使用的加密资产的价格源，Exchangerates 是法币的默认汇率价格源。

<figure><img src="/files/1ESq8bYWguWucZJ7Nron" alt=""><figcaption></figcaption></figure>

### 新建价格源

点击价格源列表右上角的添加按钮，在弹出的窗口中完善价格源信息：

<figure><img src="/files/LZuwcmgM9Vsu9avChj7l" alt="" width="563"><figcaption></figcaption></figure>

需要填写的字段包含

1. 价格源名称
2. 价格获取方式
   1. CSV：手动上传 CSV 格式的价格明细
   2. OpenAPI：通过 OpenAPI 导入价格明细 [接口文档](/v3/chinese/openapi/v3/dao-ru-jia-ge-jie-kou.md)
3. 价格时区：因为每一条价格信息都包含时间，您可以为这个价格源 指定一个时区信息
4. 报价币种

点击完成，即完成了新价格源的创建，在价格源的列表中，我们可以看到刚刚添加成功的新价格源。

<figure><img src="/files/VEPB8KoXnDr84khs0HVJ" alt=""><figcaption></figcaption></figure>

### 添加价格明细

由于我们选择了使用 CSV 上传的方式添加价格明细，所以接下来我们需要把准备好的价格文件上传到新的价格源中。

点击新添加的价格源，在右侧的详情面板中，点击“添加数据”。

<figure><img src="/files/k3oOIjxfglzGpXQnK51q" alt="" width="375"><figcaption></figcaption></figure>

把准备好的价格明细信息拖入在弹出的文件上传窗口中，进行上传。

<figure><img src="/files/MliffkTigqjNYC2ySgVI" alt="" width="563"><figcaption></figcaption></figure>

您可以下载示例模板，用于准备价格明细，一个标准的价格信息文件如下所示：

| Assets | Datetime            | Price    |
| ------ | ------------------- | -------- |
| BTC    | 2024/07/18 16:37:00 | 64696.79 |
| ETH    | 2024/07/18 16:37:00 | 3182.73  |

各列分别表示：

1. Assets：资产的代码，例如 BTC、ETH
2. Datetime：报价的时间，格式为 YYYY/MM/DD HH:MM:SS
3. Price：价格，格式为数字

如果您上传的文件中有未能识别的行，代表该行中的字段格不正确，需要进行核查之后重新上传。

<figure><img src="/files/GyE9uzEq3Qw54sCq0QoU" alt="" width="563"><figcaption></figcaption></figure>

一旦价格明细上传成功，您可以使用这个价格源了。

### 为资产指定价格源

在估值模块中，通过导航“资产”进入资产管理界面，在该列表中可以看到该主体中已经添加或者同步过的资产。

找到你需要操作的资产，如果您想要操作的资产没有出现在列表中，可以尝试[添加资产](/v3/chinese/valuation/zi-chan-guan-li/ru-he-tong-guo-zhi-neng-he-yue-di-zhi-tian-jia-token.md)。

点击需操作的资产，在右侧的详情面板中，选择目标价格源。

<figure><img src="/files/qklchWapG93NDUpxOEdT" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="warning" %}
请注意，如果您在修改资产的价格源时，已有交易记录使用了旧价格源，那么在切换到新价格源后，这些交易的价格不会自动更新，您需要在新价格源下手动执行价格修复。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.elven.com/v3/chinese/valuation/zi-chan-guan-li/wei-zi-chan-zi-ding-yi-jia-ge-yuan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
