import pathlib
import os
import dotenv


ROOT_PATH = pathlib.Path(__file__).parent.parent
_CANDLESTICK_DATASETS_RELATIVE_PATH = pathlib.Path('data/candlesticks')
_TEST_CANDLESTICK_RELATIVE_PATH = pathlib.Path('data/EURUSD_price_candlestick.csv')
CANDLESTICK_DATASETS_PATH = ROOT_PATH / _CANDLESTICK_DATASETS_RELATIVE_PATH
TEST_CANDLESTICKS_PATH = ROOT_PATH / _TEST_CANDLESTICK_RELATIVE_PATH

ENV_PATH = ROOT_PATH / '.env'

# loading secrets
dotenv.load_dotenv(ENV_PATH)


TINKOFF_TOKEN_STRING = os.environ['REAL_TINKOFF_TOKEN']
SANDBOX_TOKEN_STRING = os.environ['SANDBOX_TINKOFF_TOKEN']


BEARER_TOKEN_HEAD = "Bearer "
TINKOFF_AUTHORIZATION_HEADER = "authorization"
TINKOFF_API_ADDRESS = 'invest-public-api.tinkoff.ru:443'
TINKOFF_BEARER_TOKEN = BEARER_TOKEN_HEAD + TINKOFF_TOKEN_STRING
SANDBOX_BEARER_TOKEN = BEARER_TOKEN_HEAD + SANDBOX_TOKEN_STRING
DEFAULT_INSTRUMENT_STATUS = "base"

PART_NUMBER_FIELD = "part_number"
DEFAULT_PART_NUMBER = 0

# TODO: add autodetection
MARKETDATA_CONNECTION_LIMIT_SUBSCRIPTIONS = 300

DATA_PATH = ROOT_PATH / "data"
TRADES_DATA_PATH = DATA_PATH / "trades_data"
CURRENCIES_TRADES_PATH = TRADES_DATA_PATH / "currencies"
SHARES_TRADES_PATH = TRADES_DATA_PATH / "shares"
STATS_PATH = DATA_PATH / "stats"
SHARES_STATS_PATH = STATS_PATH / "shares_stats.json"
