Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration Modules for creating user directory, configuration loading... #175

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions finrl/config/check_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
from typing import Any, Dict

from finrl.exceptions import OperationalException
from finrl.exchange import (available_exchanges, get_exchange_bad_reason, is_exchange_bad,
is_exchange_known_ccxt, is_exchange_officially_supported)
from finrl.exchange import (
available_exchanges,
get_exchange_bad_reason,
is_exchange_bad,
is_exchange_known_ccxt,
is_exchange_officially_supported)
from finrl.state import RunMode


Expand All @@ -26,21 +30,21 @@ def remove_credentials(config: Dict[str, Any]) -> None:
def check_exchange(config: Dict[str, Any], check_for_bad: bool = True) -> bool:
"""
Check if the exchange name in the config file is supported by ccxt

Parameters:
-----------
check_for_bad:
check_for_bad:
if True, check the exchange against the list of known 'bad' exchanges
Return:

Return:
-------
False if exchange is 'bad', i.e. is known to work with the bot with
False if exchange is 'bad', i.e. is known to work with the bot with
critical issues or does not work at all, crashes, etc. True otherwise.
raises an exception if the exchange if not supported by ccxt.
"""

if (config['runmode'] in [RunMode.PLOT, RunMode.UTIL_NO_EXCHANGE, RunMode.OTHER]
and not config.get('exchange', {}).get('name')):
if (config['runmode'] in [RunMode.PLOT, RunMode.UTIL_NO_EXCHANGE,
RunMode.OTHER] and not config.get('exchange', {}).get('name')):
# Skip checking exchange in plot mode, since it requires no exchange
return True
logger.info("Checking exchange...")
Expand All @@ -51,29 +55,30 @@ def check_exchange(config: Dict[str, Any], check_for_bad: bool = True) -> bool:
f'This command requires a configured exchange. You should either use '
f'`--exchange <exchange_name>` or specify a configuration file via `--config`.\n'
f'The following exchanges are available for: '
f'{", ".join(available_exchanges())}'
)
f'{", ".join(available_exchanges())}')

if not is_exchange_known_ccxt(exchange):
raise OperationalException(
f'Exchange "{exchange}" is not known to the ccxt library '
f'and therefore not available for the bot.\n'
f'The following exchanges are available: '
f'{", ".join(available_exchanges())}'
f'Exchange "{exchange}" is not known to the ccxt library '
f'and therefore not available for the bot.\n'
f'The following exchanges are available: '
f'{", ".join(available_exchanges())}'
)

if check_for_bad and is_exchange_bad(exchange):
raise OperationalException(f'Exchange "{exchange}" is known to not work with the bot yet. '
f'Reason: {get_exchange_bad_reason(exchange)}')
raise OperationalException(
f'Exchange "{exchange}" is known to not work with the bot yet. '
f'Reason: {get_exchange_bad_reason(exchange)}')

if is_exchange_officially_supported(exchange):
logger.info(f'Exchange "{exchange}" is officially supported '
f'by FinRL.')
else:
logger.warning(f'Exchange "{exchange}" is known to the the ccxt library, '
f'available for the bot, but not officially supported '
f'by FinRL. '
f'It may work flawlessly (please report back) or have serious issues. '
f'Use it at your own discretion.')
logger.warning(
f'Exchange "{exchange}" is known to the the ccxt library, '
f'available for the bot, but not officially supported '
f'by FinRL. '
f'It may work flawlessly (please report back) or have serious issues. '
f'Use it at your own discretion.')

return True
221 changes: 117 additions & 104 deletions finrl/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,24 @@

START_TRADE_DATE = "2019-01-01"

## dataset default columns
# dataset default columns
DEFAULT_DATA_COLUMNS = ["date", "tic", "close"]

## stockstats technical indicator column names
## check https://pypi.org/project/stockstats/ for different names
TECHNICAL_INDICATORS_LIST = ["macd","boll_ub","boll_lb","rsi_30", "cci_30", "dx_30","close_30_sma","close_60_sma"]
# stockstats technical indicator column names
# check https://pypi.org/project/stockstats/ for different names
TECHNICAL_INDICATORS_LIST = [
"macd",
"boll_ub",
"boll_lb",
"rsi_30",
"cci_30",
"dx_30",
"close_30_sma",
"close_60_sma",
]


## Model Parameters
# Model Parameters
A2C_PARAMS = {"n_steps": 5, "ent_coef": 0.01, "learning_rate": 0.0007}
PPO_PARAMS = {
"n_steps": 2048,
Expand All @@ -53,7 +62,10 @@
"batch_size": 64,
}
DDPG_PARAMS = {"batch_size": 128, "buffer_size": 50000, "learning_rate": 0.001}
TD3_PARAMS = {"batch_size": 100, "buffer_size": 1000000, "learning_rate": 0.001}
TD3_PARAMS = {
"batch_size": 100,
"buffer_size": 1000000,
"learning_rate": 0.001}
SAC_PARAMS = {
"batch_size": 64,
"buffer_size": 100000,
Expand All @@ -69,31 +81,31 @@

# self defined
SRI_KEHATI_TICKER = [
"AALI.JK",
"ADHI.JK",
"ASII.JK",
"BBCA.JK",
"BBNI.JK",
"BBRI.JK",
"BBTN.JK",
"BMRI.JK",
"BSDE.JK",
"INDF.JK",
"JPFA.JK",
"JSMR.JK",
"KLBF.JK",
"PGAS.JK",
"PJAA.JK",
"PPRO.JK",
"SIDO.JK",
"SMGR.JK",
"TINS.JK",
"TLKM.JK",
"UNTR.JK",
"UNVR.JK",
"WIKA.JK",
"WSKT.JK",
"WTON.JK"
"AALI.JK",
"ADHI.JK",
"ASII.JK",
"BBCA.JK",
"BBNI.JK",
"BBRI.JK",
"BBTN.JK",
"BMRI.JK",
"BSDE.JK",
"INDF.JK",
"JPFA.JK",
"JSMR.JK",
"KLBF.JK",
"PGAS.JK",
"PJAA.JK",
"PPRO.JK",
"SIDO.JK",
"SMGR.JK",
"TINS.JK",
"TLKM.JK",
"UNTR.JK",
"UNVR.JK",
"WIKA.JK",
"WSKT.JK",
"WTON.JK",
]

# check https://wrds-www.wharton.upenn.edu/ for U.S. index constituents
Expand Down Expand Up @@ -1214,78 +1226,79 @@

###Jan 20,2020, added by YuQing Huang###################
################FX Ticker Setup Start###################
FX_TICKER = ["AUDCAD",
"AUDCHF",
"AUDJPY",
"AUDNZD",
"AUDSGD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"CADCHF",
"CADHKD",
"CADJPY",
"CHFJPY",
"CHFSGD",
"EURAUD",
"EURCAD",
"EURCHF",
"EURCHF",
"EURCHF",
"EURCZK",
"EURGBP",
"EURHKD",
"EURHUF",
"EURJPY",
"EURNOK",
"EURNZD",
"EURPLN",
"EURRUB",
"EURSEK",
"EURSGD",
"EURTRY",
"EURTRY",
"EURUSD",
"GBPAUD",
"GBPAUD",
"GBPAUD",
"GBPCAD",
"GBPCHF",
"GBPJPY",
"GBPNZD",
"GBPUSD",
"HKDJPY",
"NZDCAD",
"NZDCHF",
"NZDJPY",
"NZDUSD",
"SGDJPY",
"TRYJPY",
"USDCAD",
"USDCHF",
"USDCNH",
"USDCZK",
"USDHKD",
"USDHUF",
"USDILS",
"USDJPY",
"USDMXN",
"USDNOK",
"USDPLN",
"USDRON",
"USDRUB",
"USDSEK",
"USDSGD",
"USDTHB",
"USDTRY",
"USDZAR",
"XAGUSD",
"XAUUSD",
"ZARJPY",
"EURDKK"
FX_TICKER = [
"AUDCAD",
"AUDCHF",
"AUDJPY",
"AUDNZD",
"AUDSGD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"AUDUSD",
"CADCHF",
"CADHKD",
"CADJPY",
"CHFJPY",
"CHFSGD",
"EURAUD",
"EURCAD",
"EURCHF",
"EURCHF",
"EURCHF",
"EURCZK",
"EURGBP",
"EURHKD",
"EURHUF",
"EURJPY",
"EURNOK",
"EURNZD",
"EURPLN",
"EURRUB",
"EURSEK",
"EURSGD",
"EURTRY",
"EURTRY",
"EURUSD",
"GBPAUD",
"GBPAUD",
"GBPAUD",
"GBPCAD",
"GBPCHF",
"GBPJPY",
"GBPNZD",
"GBPUSD",
"HKDJPY",
"NZDCAD",
"NZDCHF",
"NZDJPY",
"NZDUSD",
"SGDJPY",
"TRYJPY",
"USDCAD",
"USDCHF",
"USDCNH",
"USDCZK",
"USDHKD",
"USDHUF",
"USDILS",
"USDJPY",
"USDMXN",
"USDNOK",
"USDPLN",
"USDRON",
"USDRUB",
"USDSEK",
"USDSGD",
"USDTHB",
"USDTRY",
"USDZAR",
"XAGUSD",
"XAUUSD",
"ZARJPY",
"EURDKK",
]
################FX Ticker Setup End###################
9 changes: 5 additions & 4 deletions finrl/config/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
logger = logging.getLogger(__name__)


def setup_utils_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str, Any]:
def setup_utils_configuration(
args: Dict[str, Any], method: RunMode) -> Dict[str, Any]:
"""
Prepare the configuration for utils subcommands

Parameters:
-----------
args:
args:
Cli args from Arguments()

Return:
-------
Configuration
Expand Down
Loading