Feature/cryptosentiment (#537)

* Add separate view for finbrain for crypto curreny sentiment analysis

* Move json with symbols to separate directory, little refactoring, update readme

* Add screenshot of finbrain for PolkaDot
This commit is contained in:
jp
2021-07-11 01:37:55 +02:00
committed by GitHub
parent 06e7d10770
commit 1eb7589225
4 changed files with 643 additions and 0 deletions

View File

@@ -5,8 +5,34 @@ This menu aims to explore crypto world, and the usage of the following commands
Note that we have added the ability to look at technical analysis in the ta menu. Data loaded from CoinGecko has no candle data,
so indicators that rely on anything other than close will fail with an error.
* [finbrain](#finbrain)
* crypto sentiment from 15+ major news headlines for more then 100 coins
[COINGECKO standalone menu](/gamestonk_terminal/cryptocurrency/coingecko/)
[COINMARKETCAP standalone menu](/gamestonk_terminal/cryptocurrency/coinmarketcap/)
[BINANCE standalone menu](/gamestonk_terminal/cryptocurrency/binance/)
## finbrain <a name="finbrain"></a>
```bash
usage: finbrain [-c --coin]
```
FinBrain collects the news headlines from 15+ major financial news sources on a daily basis and analyzes them to generate sentiment scores for more than 4500 US stocks. FinBrain Technologies develops deep learning algorithms for financial analysis and prediction, which currently serves traders from more than 150 countries all around the world. [Source: See https://finbrain.tech]
Currently all sentiment is gathered for `COIN-USD` pairs. Please use upper case symbols of coins.
* -c/--coin - Symbol of the Coin for which you want to analyse sentiment. Currently available coins are:
```
AAVE, ADA, ADX, AE, ANT, ARDR, ARK, ATOM, BAT, BCCOIN, BCH, BCN, BLOCK, BNB, BNT, BTC, BTCD, BTG, BTM, BTS, CVC, DASH,
DCN, DCR, DGB, DGD, DNT, DOGE, DOT, EDG, EOS, ETH, ETP, FAIR, FCT, FUN, GAME, GAS, GBYTE, GNO, GNT, HSR, ICX, IOC, KIN,
KMD, KNC, LINK, LKK, LRC, LSK, LTC, MAID, MCAP, MCO, MGO, MKR, MLN, MONA, MTL, NAV, NEBL, NEO, NLC2, NXS, NXT, OMG, PAY,
PIVX, PPT, QASH, QRL, QTUM, REP, RLC, SALT, SC, SMART, SNGLS, STEEM, STORJ, SUB, SYS, TAAS, TRX, UBQ, UNI, USDT, VEN,
VERI, VTC, WAVES, WINGS, WTC, XCP, XLM, XMR, XRP, XTZ, XVG, YFI, ZEC, ZEN, ZRX
```
![image](https://user-images.githubusercontent.com/275820/125166701-126a3f00-e19d-11eb-9f81-26c844f7dd62.png)

View File

@@ -11,6 +11,7 @@ from gamestonk_terminal.menu import session
from gamestonk_terminal.cryptocurrency.coinmarketcap import coinmarketcap_controller
from gamestonk_terminal.cryptocurrency.binance import binance_controller
from gamestonk_terminal.cryptocurrency.coingecko import pycoingecko_controller
from gamestonk_terminal.cryptocurrency import finbrain_crypto_view
class CryptoController:
@@ -24,6 +25,7 @@ class CryptoController:
"cg",
"bin",
"cmc",
"finbrain",
]
def __init__(self):
@@ -43,6 +45,8 @@ class CryptoController:
print(" q quit this menu, and shows back to main menu")
print(" quit quit to abandon program")
print("")
print(" finbrain Crypto sentiment from 15+ major news headlines")
print("")
print("> cg CoinGecko overview (market statistics) and coin menu")
print("> cmc Coinmarketcap menu")
print("> bin Binance menu with order book, candles, ta.. ")
@@ -109,6 +113,10 @@ class CryptoController:
return True
print("")
def call_finbrain(self, other_args):
"""Process sentiment command"""
finbrain_crypto_view.crypto_sentiment_analysis(other_args=other_args)
def menu():
crypto_controller = CryptoController()

View File

@@ -0,0 +1,522 @@
[
{
"PAIR": "AAVE-USD",
"SYMBOL": "AAVE",
"VS": "USD"
},
{
"PAIR": "ADA-USD",
"SYMBOL": "ADA",
"VS": "USD"
},
{
"PAIR": "ADX-USD",
"SYMBOL": "ADX",
"VS": "USD"
},
{
"PAIR": "AE-USD",
"SYMBOL": "AE",
"VS": "USD"
},
{
"PAIR": "ANT-USD",
"SYMBOL": "ANT",
"VS": "USD"
},
{
"PAIR": "ARDR-USD",
"SYMBOL": "ARDR",
"VS": "USD"
},
{
"PAIR": "ARK-USD",
"SYMBOL": "ARK",
"VS": "USD"
},
{
"PAIR": "ATOM-USD",
"SYMBOL": "ATOM",
"VS": "USD"
},
{
"PAIR": "BAT-USD",
"SYMBOL": "BAT",
"VS": "USD"
},
{
"PAIR": "BCCOIN-USD",
"SYMBOL": "BCCOIN",
"VS": "USD"
},
{
"PAIR": "BCH-USD",
"SYMBOL": "BCH",
"VS": "USD"
},
{
"PAIR": "BCN-USD",
"SYMBOL": "BCN",
"VS": "USD"
},
{
"PAIR": "BLOCK-USD",
"SYMBOL": "BLOCK",
"VS": "USD"
},
{
"PAIR": "BNB-USD",
"SYMBOL": "BNB",
"VS": "USD"
},
{
"PAIR": "BNT-USD",
"SYMBOL": "BNT",
"VS": "USD"
},
{
"PAIR": "BTC-USD",
"SYMBOL": "BTC",
"VS": "USD"
},
{
"PAIR": "BTCD-USD",
"SYMBOL": "BTCD",
"VS": "USD"
},
{
"PAIR": "BTG-USD",
"SYMBOL": "BTG",
"VS": "USD"
},
{
"PAIR": "BTM-USD",
"SYMBOL": "BTM",
"VS": "USD"
},
{
"PAIR": "BTS-USD",
"SYMBOL": "BTS",
"VS": "USD"
},
{
"PAIR": "CVC-USD",
"SYMBOL": "CVC",
"VS": "USD"
},
{
"PAIR": "DASH-USD",
"SYMBOL": "DASH",
"VS": "USD"
},
{
"PAIR": "DCN-USD",
"SYMBOL": "DCN",
"VS": "USD"
},
{
"PAIR": "DCR-USD",
"SYMBOL": "DCR",
"VS": "USD"
},
{
"PAIR": "DGB-USD",
"SYMBOL": "DGB",
"VS": "USD"
},
{
"PAIR": "DGD-USD",
"SYMBOL": "DGD",
"VS": "USD"
},
{
"PAIR": "DNT-USD",
"SYMBOL": "DNT",
"VS": "USD"
},
{
"PAIR": "DOGE-USD",
"SYMBOL": "DOGE",
"VS": "USD"
},
{
"PAIR": "DOT-USD",
"SYMBOL": "DOT",
"VS": "USD"
},
{
"PAIR": "EDG-USD",
"SYMBOL": "EDG",
"VS": "USD"
},
{
"PAIR": "EOS-USD",
"SYMBOL": "EOS",
"VS": "USD"
},
{
"PAIR": "ETH-USD",
"SYMBOL": "ETH",
"VS": "USD"
},
{
"PAIR": "ETP-USD",
"SYMBOL": "ETP",
"VS": "USD"
},
{
"PAIR": "FAIR-USD",
"SYMBOL": "FAIR",
"VS": "USD"
},
{
"PAIR": "FCT-USD",
"SYMBOL": "FCT",
"VS": "USD"
},
{
"PAIR": "FUN-USD",
"SYMBOL": "FUN",
"VS": "USD"
},
{
"PAIR": "GAME-USD",
"SYMBOL": "GAME",
"VS": "USD"
},
{
"PAIR": "GAS-USD",
"SYMBOL": "GAS",
"VS": "USD"
},
{
"PAIR": "GBYTE-USD",
"SYMBOL": "GBYTE",
"VS": "USD"
},
{
"PAIR": "GNO-USD",
"SYMBOL": "GNO",
"VS": "USD"
},
{
"PAIR": "GNT-USD",
"SYMBOL": "GNT",
"VS": "USD"
},
{
"PAIR": "HSR-USD",
"SYMBOL": "HSR",
"VS": "USD"
},
{
"PAIR": "ICX-USD",
"SYMBOL": "ICX",
"VS": "USD"
},
{
"PAIR": "IOC-USD",
"SYMBOL": "IOC",
"VS": "USD"
},
{
"PAIR": "KIN-USD",
"SYMBOL": "KIN",
"VS": "USD"
},
{
"PAIR": "KMD-USD",
"SYMBOL": "KMD",
"VS": "USD"
},
{
"PAIR": "KNC-USD",
"SYMBOL": "KNC",
"VS": "USD"
},
{
"PAIR": "LINK-USD",
"SYMBOL": "LINK",
"VS": "USD"
},
{
"PAIR": "LKK-USD",
"SYMBOL": "LKK",
"VS": "USD"
},
{
"PAIR": "LRC-USD",
"SYMBOL": "LRC",
"VS": "USD"
},
{
"PAIR": "LSK-USD",
"SYMBOL": "LSK",
"VS": "USD"
},
{
"PAIR": "LTC-USD",
"SYMBOL": "LTC",
"VS": "USD"
},
{
"PAIR": "MAID-USD",
"SYMBOL": "MAID",
"VS": "USD"
},
{
"PAIR": "MCAP-USD",
"SYMBOL": "MCAP",
"VS": "USD"
},
{
"PAIR": "MCO-USD",
"SYMBOL": "MCO",
"VS": "USD"
},
{
"PAIR": "MGO-USD",
"SYMBOL": "MGO",
"VS": "USD"
},
{
"PAIR": "MKR-USD",
"SYMBOL": "MKR",
"VS": "USD"
},
{
"PAIR": "MLN-USD",
"SYMBOL": "MLN",
"VS": "USD"
},
{
"PAIR": "MONA-USD",
"SYMBOL": "MONA",
"VS": "USD"
},
{
"PAIR": "MTL-USD",
"SYMBOL": "MTL",
"VS": "USD"
},
{
"PAIR": "NAV-USD",
"SYMBOL": "NAV",
"VS": "USD"
},
{
"PAIR": "NEBL-USD",
"SYMBOL": "NEBL",
"VS": "USD"
},
{
"PAIR": "NEO-USD",
"SYMBOL": "NEO",
"VS": "USD"
},
{
"PAIR": "NLC2-USD",
"SYMBOL": "NLC2",
"VS": "USD"
},
{
"PAIR": "NXS-USD",
"SYMBOL": "NXS",
"VS": "USD"
},
{
"PAIR": "NXT-USD",
"SYMBOL": "NXT",
"VS": "USD"
},
{
"PAIR": "OMG-USD",
"SYMBOL": "OMG",
"VS": "USD"
},
{
"PAIR": "PAY-USD",
"SYMBOL": "PAY",
"VS": "USD"
},
{
"PAIR": "PIVX-USD",
"SYMBOL": "PIVX",
"VS": "USD"
},
{
"PAIR": "PPT-USD",
"SYMBOL": "PPT",
"VS": "USD"
},
{
"PAIR": "QASH-USD",
"SYMBOL": "QASH",
"VS": "USD"
},
{
"PAIR": "QRL-USD",
"SYMBOL": "QRL",
"VS": "USD"
},
{
"PAIR": "QTUM-USD",
"SYMBOL": "QTUM",
"VS": "USD"
},
{
"PAIR": "REP-USD",
"SYMBOL": "REP",
"VS": "USD"
},
{
"PAIR": "RLC-USD",
"SYMBOL": "RLC",
"VS": "USD"
},
{
"PAIR": "SALT-USD",
"SYMBOL": "SALT",
"VS": "USD"
},
{
"PAIR": "SC-USD",
"SYMBOL": "SC",
"VS": "USD"
},
{
"PAIR": "SMART-USD",
"SYMBOL": "SMART",
"VS": "USD"
},
{
"PAIR": "SNGLS-USD",
"SYMBOL": "SNGLS",
"VS": "USD"
},
{
"PAIR": "STEEM-USD",
"SYMBOL": "STEEM",
"VS": "USD"
},
{
"PAIR": "STORJ-USD",
"SYMBOL": "STORJ",
"VS": "USD"
},
{
"PAIR": "SUB-USD",
"SYMBOL": "SUB",
"VS": "USD"
},
{
"PAIR": "SYS-USD",
"SYMBOL": "SYS",
"VS": "USD"
},
{
"PAIR": "TAAS-USD",
"SYMBOL": "TAAS",
"VS": "USD"
},
{
"PAIR": "TRX-USD",
"SYMBOL": "TRX",
"VS": "USD"
},
{
"PAIR": "UBQ-USD",
"SYMBOL": "UBQ",
"VS": "USD"
},
{
"PAIR": "UNI-USD",
"SYMBOL": "UNI",
"VS": "USD"
},
{
"PAIR": "USDT-USD",
"SYMBOL": "USDT",
"VS": "USD"
},
{
"PAIR": "VEN-USD",
"SYMBOL": "VEN",
"VS": "USD"
},
{
"PAIR": "VERI-USD",
"SYMBOL": "VERI",
"VS": "USD"
},
{
"PAIR": "VTC-USD",
"SYMBOL": "VTC",
"VS": "USD"
},
{
"PAIR": "WAVES-USD",
"SYMBOL": "WAVES",
"VS": "USD"
},
{
"PAIR": "WINGS-USD",
"SYMBOL": "WINGS",
"VS": "USD"
},
{
"PAIR": "WTC-USD",
"SYMBOL": "WTC",
"VS": "USD"
},
{
"PAIR": "XCP-USD",
"SYMBOL": "XCP",
"VS": "USD"
},
{
"PAIR": "XLM-USD",
"SYMBOL": "XLM",
"VS": "USD"
},
{
"PAIR": "XMR-USD",
"SYMBOL": "XMR",
"VS": "USD"
},
{
"PAIR": "XRP-USD",
"SYMBOL": "XRP",
"VS": "USD"
},
{
"PAIR": "XTZ-USD",
"SYMBOL": "XTZ",
"VS": "USD"
},
{
"PAIR": "XVG-USD",
"SYMBOL": "XVG",
"VS": "USD"
},
{
"PAIR": "YFI-USD",
"SYMBOL": "YFI",
"VS": "USD"
},
{
"PAIR": "ZEC-USD",
"SYMBOL": "ZEC",
"VS": "USD"
},
{
"PAIR": "ZEN-USD",
"SYMBOL": "ZEN",
"VS": "USD"
},
{
"PAIR": "ZRX-USD",
"SYMBOL": "ZRX",
"VS": "USD"
}
]

View File

@@ -0,0 +1,87 @@
"""Finbrain Crypto Sentiment Analysis"""
__docformat__ = "numpy"
import os
import argparse
from typing import List
import pandas as pd
from gamestonk_terminal.helper_funcs import (
parse_known_args_and_warn,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.behavioural_analysis.finbrain_view import (
get_sentiment,
plot_sentiment,
sentiment_coloring,
)
PATH = os.path.dirname(os.path.abspath(__file__))
try:
COINS_JSON = pd.read_json(PATH + "/data/finbrain_coins.json")
COINS = COINS_JSON["SYMBOL"].tolist()
except ValueError:
COINS = None
def crypto_sentiment_analysis(other_args: List[str]):
"""Sentiment analysis from FinBrain for Cryptocurrencies
Parameters
----------
other_args : List[str]
Command line arguments to be processed with argparse
"""
parser = argparse.ArgumentParser(
prog="finbrain",
add_help=False,
description="""FinBrain collects the news headlines from 15+ major financial news
sources on a daily basis and analyzes them to generate sentiment scores
for more than 4500 US stocks. FinBrain Technologies develops deep learning
algorithms for financial analysis and prediction, which currently serves
traders from more than 150 countries all around the world.
[Source: https://finbrain.tech]""",
)
parser.add_argument(
"-c",
"--coin",
default="BTC",
type=str,
dest="coin",
help="Symbol of coin to load data for, ~100 symbols are available",
choices=COINS,
)
try:
ns_parser = parse_known_args_and_warn(parser, other_args)
if not ns_parser:
return
coin = ns_parser.coin
df_sentiment = get_sentiment(
f"{coin}-USD"
) # Currently only USD pairs are available
if df_sentiment.empty:
print(f"Couldn't find Sentiment Data for {coin}")
return
plot_sentiment(df_sentiment, coin)
df_sentiment.sort_index(ascending=True, inplace=True)
if gtff.USE_COLOR:
print(
df_sentiment["Sentiment Analysis"]
.apply(sentiment_coloring, last_val=0)
.to_string()
)
else:
print(df_sentiment.to_string())
print("")
except Exception as e:
print(e)
print("")