Skip to content

Commit f67c95e

Browse files
authored
Merge pull request #134 from Wukkkinz-0725/feat/add_currents_and_coingecko
feat: add currents and coingecko
2 parents 283b35d + 3fb7dc8 commit f67c95e

File tree

12 files changed

+522
-0
lines changed

12 files changed

+522
-0
lines changed

Diff for: README.md

+150
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,104 @@ result
778778

779779
</details>
780780

781+
#### [CoinGecko](./coingecko) -- Collect Cryptocurrency Data
782+
783+
<details>
784+
<summary>What are the 10 cryptocurrencies with highest market cap and their current information?</summary>
785+
786+
```python
787+
from dataprep.connector import connect
788+
789+
conn_coingecko = connect("coingecko")
790+
df = await conn_coingecko.query('markets', vs_currency='usd', order='market_cap_desc', per_page=10, page=1)
791+
df
792+
```
793+
| | name | symbol | current_price | market_cap | market_cap_rank | high_24h | low_24h | price_change_24h | price_change_percentage_24h | market_cap_change_24h | market_cap_change_percentage_24h | last_updated |
794+
|---:|:-------------|:---------|----------------:|-------------:|------------------:|-------------:|-------------:|-------------------:|------------------------------:|------------------------:|-----------------------------------:|:-------------------------|
795+
| 0 | Bitcoin | btc | 36811 | 6.86613e+11 | 1 | 37153 | 35344 | 1440.68 | 4.0731 | 3.10933e+10 | 4.7433 | 2021-02-03T19:24:09.271Z |
796+
| 1 | Ethereum | eth | 1628.99 | 1.87035e+11 | 2 | 1645.73 | 1486.42 | 132.91 | 8.88404 | 1.64296e+10 | 9.63018 | 2021-02-03T19:22:32.413Z |
797+
| .. | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
798+
| 9 | Binance Coin | bnb | 51.47 | 7.60256e+09 | 10 | 51.63 | 49.76 | 1.24 | 2.47631 | 1.64863e+08 | 2.21659 | 2021-02-03T19:25:45.456Z |
799+
</details>
800+
801+
<details>
802+
<summary>What are the cryptocurrencies with highest increasing and decreasing percentage?</summary>
803+
804+
```python
805+
from dataprep.connector import connect
806+
807+
conn_coingecko = connect("coingecko")
808+
df = await conn_coingecko.query('markets', vs_currency='usd', per_page=1000, page=1)
809+
df = df.sort_values(by=['price_change_percentage_24h']).reset_index(drop=True).dropna()
810+
print("Coin with highest decreasing percetage: {}, which decreases {}%".format(df['name'].iloc[0], df['price_change_percentage_24h'].iloc[0]))
811+
print("Coin with highest increasing percetage: {}, which increases {}%".format(df['name'].iloc[-1], df['price_change_percentage_24h'].iloc[-1]))
812+
```
813+
Coin with the highest decreasing percentage: `PancakeSwap`, which decreases `-13.79622%`
814+
815+
Coin with the highest increasing percentage: `StormX`, which increases `101.24182%`
816+
</details>
817+
818+
<details>
819+
<summary>Which cryptocurrencies are trending in CoinGecko?</summary>
820+
821+
```python
822+
from dataprep.connector import connect
823+
824+
conn_coingecko = connect("coingecko")
825+
df = await conn_coingecko.query('trend')
826+
df
827+
```
828+
| | id | name | symbol | market_cap_rank | score |
829+
|---:|:------------------|:------------|:---------|------------------:|--------:|
830+
| 0 | bao-finance | Bao Finance | BAO | 175 | 0 |
831+
| 1 | milk2 | MILK2 | MILK2 | 634 | 1 |
832+
| 2 | unitrade | Unitrade | TRADE | 529 | 2 |
833+
| 3 | pancakeswap-token | PancakeSwap | CAKE | 110 | 3 |
834+
| 4 | fsw-token | Falconswap | FSW | 564 | 4 |
835+
| 5 | zeroswap | ZeroSwap | ZEE | 550 | 5 |
836+
| 6 | storm | StormX | STMX | 211 | 6 |
837+
838+
</details>
839+
840+
<details>
841+
<summary>What are the 10 US exchanges with highest trade volume in the past 24 hours?</summary>
842+
843+
```python
844+
from dataprep.connector import connect
845+
846+
conn_coingecko = connect("coingecko")
847+
df = await conn_coingecko.query('exchanges')
848+
result = df[df['country']=='United States'].reset_index(drop=True).head(10)
849+
result
850+
```
851+
| | id | name | year_established | ... | trade_volume_24h_btc_normalized |
852+
|---:|:-----------|:-------------|-------------------:|:----|----------------------------------:|
853+
| 0 | gdax | Coinbase Pro | 2012 | ... | 90085.6 |
854+
| 1 | kraken | Kraken | 2011 | ... | 48633.1 |
855+
| 2 | binance_us | Binance US | 2019 | ... | 7380.83 |
856+
| .. | ... | ... | ... | ... | ... |
857+
858+
</details>
859+
860+
<details>
861+
<summary>What are the 3 latest traded derivatives with perpetual contract?</summary>
862+
863+
```python
864+
from dataprep.connector import connect
865+
import pandas as pd
866+
867+
conn_coingecko = connect("coingecko")
868+
df = await conn_coingecko.query('derivatives')
869+
perpetual_df = df[df['contract_type'] == 'perpetual'].reset_index(drop=True)
870+
perpetual_df['last_traded_at'] = pd.to_datetime(perpetual_df['last_traded_at'], unit='s')
871+
perpetual_df.sort_values(by=['last_traded_at'], ascending=False).head(3).reset_index(drop=True)
872+
```
873+
| | market | symbol | index_id | contract_type | index | basis | funding_rate | open_interest | volume_24h | last_traded_at |
874+
|---:|:---------------|:-----------|:-----------|:----------------|--------------:|----------:|---------------:|----------------:|-----------------:|:--------------------|
875+
| 0 | Huobi Futures | MATIC-USDT | MATIC | perpetual | 0.0433357 | -0.606296 | 0.247604 | nan | 1.43338e+06 | 2021-02-03 20:14:24 |
876+
| 1 | Biki (Futures) | 1 | BTC | perpetual | 36769.8 | -0.153111 | -0.0519 | nan | 1.00131e+08 | 2021-02-03 20:14:23 |
877+
| 2 | Huobi Futures | CVC-USDT | CVC | perpetual | 0.178268 | -0.336302 | 0.106314 | nan | 876960 | 2021-02-03 20:14:23 |
878+
</details>
781879

782880
### Geocoding
783881

@@ -2276,6 +2374,58 @@ ranking_df
22762374
| 5 | Kim Kardashian | 0 |
22772375
</details>
22782376

2377+
#### [Currents](./currents) -- Collect Currents News Data
2378+
<details>
2379+
<summary>How to get latest Chinese news?</summary>
2380+
2381+
```python
2382+
from dataprep.connector import connect
2383+
2384+
# You can get ”currents_access_token“ by following https://currentsapi.services/zh_CN
2385+
conn_currents = connect('currents', _auth={'access_token': currents_access_token})
2386+
df = await conn_currents.query('latest_news', language='zh')
2387+
df.head()
2388+
```
2389+
| id | title | category | ... | author | published |
2390+
|---:|:-----------------|:-------------|:----|:--------|:--------------------------|
2391+
| 0 | 為何上市公司該汰換了 |[entrepreneur]| ... | 經濟日報 | 2021-02-03 08:48:39 +0000 |
2392+
</details>
2393+
2394+
<details>
2395+
<summary>How to get the political news about 'Trump'?</summary>
2396+
2397+
```python
2398+
from dataprep.connector import connect
2399+
2400+
# You can get ”currents_access_token“ by following https://currentsapi.services/zh_CN
2401+
conn_currents = connect('currents', _auth={'access_token': currents_access_token})
2402+
df = await conn_currents.query('search', keywords='Trump', category='politics')
2403+
df.head(3)
2404+
```
2405+
| | title | category | description | url | author | published |
2406+
|---:|:-------------------------------------------------------------------------------------------------------------|:----------------------|:-------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------|:--------------|:--------------------------|
2407+
| 0 | Biden Started The Process Of Unwinding Trump's Assault On Immigration, But Activists Want Him To Move Faster | ['politics', 'world'] | "These people cannot continue to wait." | https://www.buzzfeednews.com/article/adolfoflores/biden-immigration-executive-orders-review | Adolfo Flores | 2021-02-03 08:39:51 +0000 |
2408+
| 1 | Pro-Trump lawyer Lin Wood reportedly under investigation for voter fraud | ['politics', 'world'] | A source told CBS Atlanta affiliate WGCL that Lin Wood is being investigated for allegedly voting "out of state." | https://www.cbsnews.com/news/pro-trump-lawyer-lin-wood-under-investigation-for-alleged-illegal-voting-2020-02-03/ | April Siese | 2021-02-03 08:21:25 +0000 |
2409+
| 2 | Trump Supporters Say They Attacked The Capitol Because He Told Them To, Undercutting His Impeachment Defense | ['politics', 'world'] | “President Trump told Us to ‘fight like hell,’” one Trump supporter reportedly posted online after the assault on the Capitol. | https://www.buzzfeednews.com/article/zoetillman/trump-impeachment-capitol-rioters-fight-like-hell | Zoe Tillman | 2021-02-03 07:25:34 +0000 |
2410+
</details>
2411+
2412+
<details>
2413+
<summary>How to get the news about COVID-19 from 2020-12-25?</summary>
2414+
2415+
```python
2416+
from dataprep.connector import connect
2417+
2418+
# You can get ”currents_access_token“ by following https://currentsapi.services/zh_CN
2419+
conn_currents = connect('currents', _auth={'access_token': currents_access_token})
2420+
df = await conn_currents.query('search', keywords='covid', start_date='2020-12-25',end_date='2020-12-25')
2421+
df.head(1)
2422+
```
2423+
2424+
| | title | category | ... | published |
2425+
|---:|:--------------------------------------------------------------------|:------------|:----|:--------------------------|
2426+
| 0 | Commentary: Let our charitable giving equal our political donations | ['opinion'] | ... | 2020-12-25 00:00:00 +0000 |
2427+
</details>
2428+
22792429

22802430
### Science
22812431

Diff for: api-connectors/coingecko/_meta.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tables": [
3+
"coin_list",
4+
"exchanges",
5+
"exchange_volume_chart",
6+
"markets",
7+
"trend"
8+
]
9+
}

Diff for: api-connectors/coingecko/coin_list.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "https://api.coingecko.com/api/v3/coins/list",
5+
"method": "GET",
6+
"params": {}
7+
},
8+
"response": {
9+
"ctype": "application/json",
10+
"tablePath": "$.[*]",
11+
"schema": {
12+
"id": {
13+
"target": "$.id",
14+
"type": "string"
15+
},
16+
"symbol": {
17+
"target": "$.symbol",
18+
"type": "string"
19+
},
20+
"name": {
21+
"target": "$.name",
22+
"type": "string"
23+
}
24+
},
25+
"orient": "records"
26+
}
27+
}

Diff for: api-connectors/coingecko/derivatives.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "https://api.coingecko.com/api/v3/derivatives",
5+
"method": "GET",
6+
"params": {
7+
"include_tickers": false
8+
}
9+
},
10+
"response": {
11+
"ctype": "application/json",
12+
"tablePath": "$.[*]",
13+
"schema": {
14+
"market": {
15+
"target": "$.market",
16+
"type": "string"
17+
},
18+
"symbol": {
19+
"target": "$.symbol",
20+
"type": "string"
21+
},
22+
"index_id": {
23+
"target": "$.index_id",
24+
"type": "string"
25+
},
26+
"contract_type": {
27+
"target": "$.contract_type",
28+
"type": "string"
29+
},
30+
"index": {
31+
"target": "$.index",
32+
"type": "float"
33+
},
34+
"basis": {
35+
"target": "$.basis",
36+
"type": "float"
37+
},
38+
"funding_rate": {
39+
"target": "$.funding_rate",
40+
"type": "float"
41+
},
42+
"open_interest": {
43+
"target": "$.open_interest",
44+
"type": "float"
45+
},
46+
"volume_24h": {
47+
"target": "$.volume_24h",
48+
"type": "float"
49+
},
50+
"last_traded_at": {
51+
"target": "$.last_traded_at",
52+
"type": "int"
53+
}
54+
},
55+
"orient": "records"
56+
}
57+
}

Diff for: api-connectors/coingecko/exchanges.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "https://api.coingecko.com/api/v3/exchanges",
5+
"method": "GET",
6+
"params": {
7+
"per_page": false,
8+
"page": false
9+
}
10+
},
11+
"response": {
12+
"ctype": "application/json",
13+
"tablePath": "$.[*]",
14+
"schema": {
15+
"id": {
16+
"target": "$.id",
17+
"type": "string"
18+
},
19+
"name": {
20+
"target": "$.name",
21+
"type": "string"
22+
},
23+
"year_established": {
24+
"target": "$.year_established",
25+
"type": "string"
26+
},
27+
"country": {
28+
"target": "$.country",
29+
"type": "string"
30+
},
31+
"url": {
32+
"target": "$.url",
33+
"type": "string"
34+
},
35+
"trust_score": {
36+
"target": "$.trust_score",
37+
"type": "int"
38+
},
39+
"trust_score_rank": {
40+
"target": "$.trust_score_rank",
41+
"type": "int"
42+
},
43+
"trade_volume_24h_btc": {
44+
"target": "$.trade_volume_24h_btc",
45+
"type": "float"
46+
},
47+
"trade_volume_24h_btc_normalized": {
48+
"target": "$.trade_volume_24h_btc_normalized",
49+
"type": "float"
50+
}
51+
},
52+
"orient": "records"
53+
}
54+
}

Diff for: api-connectors/coingecko/markets.json

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "https://api.coingecko.com/api/v3/coins/markets",
5+
"method": "GET",
6+
"params": {
7+
"vs_currency": true,
8+
"sparkline": false,
9+
"order": false,
10+
"per_page": false,
11+
"page": false
12+
}
13+
},
14+
"examples": {
15+
"vs_currency": "'usd'"
16+
},
17+
"response": {
18+
"ctype": "application/json",
19+
"tablePath": "$.[*]",
20+
"schema": {
21+
"name": {
22+
"target": "$.name",
23+
"type": "string"
24+
},
25+
"symbol": {
26+
"target": "$.symbol",
27+
"type": "string"
28+
},
29+
"current_price": {
30+
"target": "$.current_price",
31+
"type": "float"
32+
},
33+
"market_cap": {
34+
"target": "$.market_cap",
35+
"type": "float"
36+
},
37+
"market_cap_rank": {
38+
"target": "$.market_cap_rank",
39+
"type": "int"
40+
},
41+
"high_24h": {
42+
"target": "$.high_24h",
43+
"type": "float"
44+
},
45+
"low_24h": {
46+
"target": "$.low_24h",
47+
"type": "float"
48+
},
49+
"price_change_24h": {
50+
"target": "$.price_change_24h",
51+
"type": "float"
52+
},
53+
"price_change_percentage_24h": {
54+
"target": "$.price_change_percentage_24h",
55+
"type": "float"
56+
},
57+
"market_cap_change_24h": {
58+
"target": "$.market_cap_change_24h",
59+
"type": "float"
60+
},
61+
"market_cap_change_percentage_24h": {
62+
"target": "$.market_cap_change_percentage_24h",
63+
"type": "float"
64+
},
65+
"last_updated": {
66+
"target": "$.last_updated",
67+
"type": "string"
68+
}
69+
},
70+
"orient": "records"
71+
}
72+
}

Diff for: api-connectors/coingecko/tests/tests.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from dataprep.connector import Connector
2+
3+
4+
def test_sanity():
5+
Connector("./coingecko")

0 commit comments

Comments
 (0)