# DocumentTrends

### Function specification

```
DocumentTrends(category, section, query,
                interval="1d", date_from=None, date_to=None,
                fields=None, format=None)
```

###

### Parameters

| Parameter  | Type                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ---------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| category   | string or list of string | <p></p><p>국내뉴스:news</p><p>증권사 보고서: research</p><p>공시,IR : company</p><p>특허 : patent</p><p></p>                                                                                                                                                                                                                                                                                                                                                                                                       |
| section    | string or list of string | <p>Category가 news일 경우 </p><p>정치: politics </p><p>경제: economy </p><p>사회: society </p><p>문화: culture </p><p>세계: world </p><p>기술/IT: tech </p><p>연예: entertainment </p><p>사설: opinion </p><p></p><p>Category가 research일 경우 </p><p>시장 전망: market </p><p>투자전략: strategy </p><p>기업 보고서: company </p><p>산업 보고서: industry </p><p>경제 보고서: economy </p><p>채권 보고서: bond </p><p></p><p>Category 가 company 인 경우 </p><p>IR : ir </p><p>공시 : disclosure </p><p></p><p>Category 가 patent 인 경우 </p><p>특허 : patent</p> |
| query      | string                   | 검색 쿼리                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| interval   | string                   | <p></p><ul><li><p>트렌드 계산 단위</p><ul><li>1y: 1년 단위</li><li>1M: 1개월 단위</li><li>1w: 1주일 단위</li><li>1d: 1일 단위</li><li>1h : 1시간 단위</li><li>1m : 1분 단위</li></ul></li></ul>                                                                                                                                                                                                                                                                                                                                  |
| date\_from | string                   | 검색 시작 시점 (YYYYMMDD)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| date\_to   | string                   | 검색 종료 시점(YYYYMMDD)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| fields     | list of string           | 결과값으로 어떤 항목을 노출한 것인지 지정한다.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

### Result Layout

{% content-ref url="../../../result\_layout/result-documenttrendsresult" %}
[result-documenttrendsresult](https://help.deepsearch.com/dp/api/result_layout/result-documenttrendsresult)
{% endcontent-ref %}

### Examples

```
핀테크 트렌드 검색
> DocumentTrends(["news"],[""],"핀테크")

...
query: {
query_name: "핀테크",
query_string: ""핀테크""
},
total_matches: 105447,
buckets: [
{
key: "1990-01-17",
value: 0,
count: 0,
frequencies: [ ]
},
{
key: "1990-01-18",
value: 0,
count: 0,
frequencies: [ ]
},
{
key: "1990-01-19",
value: 0,
count: 0,
frequencies: [ ]
},
{
key: "1990-01-20",
value: 0,
count: 0,
frequencies: [ ]
},
...


> DocumentTrends(["world-news"],[""],"TESLA")

```

### 활용예시

#### DocumentTrends 를 이용한 특정 주제에 대한 긍부정 점수 계산

긍부정 점수 = ( 긍정 뉴스 개수 - 부정 뉴스 개수 ) / ( 긍정 뉴스 개수 + 중립 뉴스 개수 + 부정 뉴스 개수 )

* 긍정 뉴스 개수 : api.deepsearch.com/v1/compute?input=DocumentTrends(\["news"],\[""],"키워드%20polarity.label:'1'",interval="1M",date\_from=2019-01-01)
* 부정 뉴스 개수: api.deepsearch.com/v1/compute?input=DocumentTrends(\["news"],\[""],"키워드%20polarity.label:'-1'",interval="1M",date\_from=2019-01-01)
* 중립 뉴스 개수: api.deepsearch.com/v1/compute?input=DocumentTrends(\["news"],\[""],"키워드%20polarity.label:'0'",interval="1M",date\_from=2019-01-01)

```
예시 ) 삼성전자

긍정 점수 :
api.deepsearch.com/v1/compute?input=DocumentTrends(["news"],[""],"삼성전자%20polarity.label:1",interval="1M",date_from=2019-01-01)

key: "2019-01-01",
value: 0.189542,
count: 1475,

부정 점수 :
api.deepsearch.com/v1/compute?input=DocumentTrends(["news"],[""],"삼성전자%20polarity.label:-1",interval="1M",date_from=2019-01-01)

key: "2019-01-01",
value: 44.386932,
count: 345416,

중립 점수 :
api.deepsearch.com/v1/compute?input=DocumentTrends(["news"],[""],"삼성전자%20polarity.label:0",interval="1M",date_from=2019-01-01)

key: "2019-01-01",
value: 0.230534,
count: 1794,


2019년 1월 긍부정 점수
(1475-345416)/(1475+345416+1794) = -0.98

```
