Ejemplo n.º 1
0
    Location,
    Timestamp,
    TradeType,
)
from rotkehlchen.user_messages import MessagesAggregator
from rotkehlchen.utils.misc import ts_now_in_ms
from rotkehlchen.utils.mixins.cacheable import cache_response_timewise
from rotkehlchen.utils.mixins.lockable import protect_with_lock
from rotkehlchen.utils.serialization import jsonloads_dict

if TYPE_CHECKING:
    from rotkehlchen.db.dbhandler import DBHandler


logger = logging.getLogger(__name__)
log = RotkehlchenLogsAdapter(logger)


API_SYSTEM_CLOCK_NOT_SYNCED_ERROR_CODE = 400002
# More understandable explanation for API key-related errors than the default `reason`
API_KEY_ERROR_CODE_ACTION = {
    API_SYSTEM_CLOCK_NOT_SYNCED_ERROR_CODE: 'Invalid timestamp. Is your system clock synced?',
    400003: 'Invalid API key value.',
    400004: 'Invalid API passphrase.',
    400005: 'Invalid API secret.',
    400007: 'Provided KuCoin API key needs to have "General" permission activated.',
    411100: 'Contact KuCoin support to unfreeze your account',
}
API_PAGE_SIZE_LIMIT = 500
# Once the rate limit is exceeded, the system will restrict your use of your IP or account for 10s.
# https://docs.kucoin.com/#request-rate-limit
Ejemplo n.º 2
0
from rotkehlchen.fval import FVal
from rotkehlchen.globaldb.manual_price_oracle import ManualPriceOracle
from rotkehlchen.inquirer import Inquirer
from rotkehlchen.logging import RotkehlchenLogsAdapter
from rotkehlchen.types import Price, Timestamp
from rotkehlchen.user_messages import MessagesAggregator

from .types import HistoricalPriceOracle, HistoricalPriceOracleInstance

if TYPE_CHECKING:
    from rotkehlchen.accounting.structures.balance import Balance
    from rotkehlchen.externalapis.coingecko import Coingecko
    from rotkehlchen.externalapis.cryptocompare import Cryptocompare

logger = logging.getLogger(__name__)
log = RotkehlchenLogsAdapter(logger)


def query_usd_price_or_use_default(
    asset: Asset,
    time: Timestamp,
    default_value: FVal,
    location: str,
) -> Price:
    try:
        usd_price = PriceHistorian().query_historical_price(
            from_asset=asset,
            to_asset=A_USD,
            timestamp=time,
        )
    except (RemoteError, NoPriceForGivenTimestamp):
Ejemplo n.º 3
0
    deserialize_asset_amount,
    deserialize_fee,
    deserialize_price,
    deserialize_timestamp_from_bitstamp_date,
)
from rotkehlchen.typing import ApiKey, ApiSecret, Location, Timestamp, TradePair
from rotkehlchen.user_messages import MessagesAggregator
from rotkehlchen.utils.interfaces import cache_response_timewise, protect_with_lock
from rotkehlchen.utils.misc import ts_now_in_ms
from rotkehlchen.utils.serialization import rlk_jsonloads_dict, rlk_jsonloads_list

if TYPE_CHECKING:
    from rotkehlchen.db.dbhandler import DBHandler

logger = logging.getLogger(__name__)
log = RotkehlchenLogsAdapter(logger)

API_SYSTEM_CLOCK_NOT_SYNCED_ERROR_CODE = 'API0017'
# More understandable explanation for API key-related errors than the default `reason`
API_KEY_ERROR_CODE_ACTION = {
    'API0001':
    'Check your API key value.',
    'API0002':
    'The IP address has no permission to use this API key.',
    'API0003':
    ('Provided Bitstamp API key needs to have "Account balance" and "User transactions" '
     'permission activated. Please log into your Bitstamp account and create a key with '
     'the required permissions.'),
    'API0006':
    'Contact Bitstamp support to unfreeze your account',
    'API0008':
Ejemplo n.º 4
0
    Fee,
    Location,
    Timestamp,
    TradePair,
    TradeType,
)
from rotkehlchen.user_messages import MessagesAggregator
from rotkehlchen.utils.interfaces import cache_response_timewise, protect_with_lock
from rotkehlchen.utils.misc import ts_now_in_ms
from rotkehlchen.utils.serialization import rlk_jsonloads, rlk_jsonloads_list

if TYPE_CHECKING:
    from rotkehlchen.db.dbhandler import DBHandler

logger = logging.getLogger(__name__)
log = RotkehlchenLogsAdapter(logger)


# Error codes that we handle nicely
API_ERR_AUTH_NONCE_CODE = 10114  # small nonce (from timestamp in ms)
API_ERR_AUTH_NONCE_MESSAGE = (
    'Bitfinex nonce too low error. Is the local system clock in synced?'
)
API_KEY_ERROR_CODE = 10100
API_KEY_ERROR_MESSAGE = (
    'Provided API key/secret is invalid or does not have enough permissions. '
    'Make sure it has get/read permission of both "Balances" and "Account History" enabled.'
)
# Rate Limits and retry
API_RATE_LIMITS_ERROR_MESSAGE = 'ERR_RATE_LIMIT'
API_REQUEST_RETRY_TIMES = 2
Ejemplo n.º 5
0
from rotkehlchen.serialization.deserialize import (
    deserialize_asset_amount,
    deserialize_fee,
    deserialize_timestamp_from_bitstamp_date,
)
from rotkehlchen.typing import ApiKey, ApiSecret, AssetAmount, Location, Timestamp
from rotkehlchen.user_messages import MessagesAggregator
from rotkehlchen.utils.misc import ts_now_in_ms
from rotkehlchen.utils.mixins import cache_response_timewise, protect_with_lock
from rotkehlchen.utils.serialization import jsonloads_dict, jsonloads_list

if TYPE_CHECKING:
    from rotkehlchen.db.dbhandler import DBHandler

logger = logging.getLogger(__name__)
log = RotkehlchenLogsAdapter(logger)

API_ERR_AUTH_NONCE_CODE = 'API0017'
API_ERR_AUTH_NONCE_MESSAGE = (
    'Bitstamp nonce too low error. Is the local system clock in synced?')
# More understandable explanation for API key-related errors than the default `reason`
API_KEY_ERROR_CODE_ACTION = {
    'API0001':
    'Check your API key value.',
    'API0002':
    'The IP address has no permission to use this API key.',
    'API0003':
    ('Provided Bitstamp API key needs to have "Account balance" and "User transactions" '
     'permission activated. Please log into your Bitstamp account and create a key with '
     'the required permissions.'),
    API_ERR_AUTH_NONCE_CODE: