# Path: crumpet/profiles/constants.py
# CRYPTO_EXCHANGES = (
#     ("poloniex", _("Poloniex")),
#     ("bittrex", _("Bittrex")),
#     ("bitstamp", _("Bitstamp"))
# )
# EXCHANGE_PERIODS = (
#     (300, "5-min"),
#     (900, "15-min"),
#     (1800, "30-min"),
#     (7200, "2-hr"),
#     (14400, "4-hr"),
#     (86400, "1-day")
# )
# STRATEGIES = (
#     ("To The Moon", "toTheMoon"),
#     ("Strategy 2", "strategy 2"),
# )
# INSTRUMENTS = (
#     ("ETH", _("Ethereum")),
#     ("DGB", _("DigiByte")),
#     ("XRP", _("Ripple")),
#     ("XMR", _("Monero")),
#     ("LTC", _("LiteCoin")),
#     ("LSK", _("LISK")),
#     ("STEEM", _("STEEM"))
# )
# MODES = (
#     ("backtest", _("Backtest")),
#     ("livetest", _("Live Backtest")),
#     ("live", _("Live"))
# )
#     BUY = 0
#     SELL = 1
# ORDER_TYPES = (
#     (OrderType.BUY, 'buy'),
#     (OrderType.SELL, 'sell')
# )
# OPEN, CANCELLED, PROCESSED = 'open', 'cancelled', 'processed'
# ORDER_STATES = (
#     (OPEN, _('open')),
#     (CANCELLED, _('cancelled')),
#     (PROCESSED, _('processed'))
# )
# SMA, EMA, RSI = 'sma', 'ema', 'rsi'
# INDICATORS = (
#     (SMA, _('sma')),
#     (EMA, _('ema')),
#     (RSI, _('rsi'))
# )
# class OrderType(object):
# 
# Path: crumpet/profiles/fields.py
# class PriceField(models.DecimalField):
#     def __init__(self, max_digits=30, decimal_places=2, default=0, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          default=default,
#                          **kwargs)
# 
# class PercentField(models.DecimalField):
#     def __init__(self, max_digits=8, decimal_places=3, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          **kwargs)
# 
# class AmountField(models.DecimalField):
#     def __init__(self, max_digits=30, decimal_places=8, default=0, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          default=default,
#                          **kwargs)
# 
# Path: crumpet/profiles/models.py
# class UserAccount(models.Model):
#     """User profile"""
#     user = models.OneToOneField(
#         settings.AUTH_USER_MODEL,
#         related_name="user_account"
#     )
#     exchange = models.CharField(
#         verbose_name="Crypto Exchanges",
#         choices=constants.CRYPTO_EXCHANGES,
#         default=constants.CRYPTO_EXCHANGES[0][0],
#         max_length=30
#     )
#     api_key = models.CharField(max_length=255, blank=True)
#     api_secret = models.CharField(max_length=255, blank=True)
#     created = models.DateTimeField(auto_now_add=True)
#     updated = models.DateTimeField(auto_now=True)
# 
#     class Meta:
#         verbose_name = "User Account"
# 
#     def __str__(self):
#         return u"%s %s" % (self.user.first_name, self.user.last_name)


from datetime import datetime
from allauth.account.signals import user_signed_up
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from crumpet.profiles import constants
from crumpet.profiles.fields import PriceField, PercentField, AmountField
from crumpet.profiles.models import UserAccount




@python_2_unicode_compatible
class TradingStrategyProfile(models.Model):
    """Base trading strategy configuration models class."""
    name = models.CharField(max_length=100)
    note = models.CharField(max_length=255, blank=True)
    account = models.ForeignKey(UserAccount)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)


@python_2_unicode_compatible
class FixedStrategyProfile(TradingStrategyProfile):
    """Configuration for fixed trading strategy."""
    buy = PriceField()

# Path: crumpet/profiles/constants.py
# CRYPTO_EXCHANGES = (
#     ("poloniex", _("Poloniex")),
#     ("bittrex", _("Bittrex")),
#     ("bitstamp", _("Bitstamp"))
# )
# EXCHANGE_PERIODS = (
#     (300, "5-min"),
#     (900, "15-min"),
#     (1800, "30-min"),
#     (7200, "2-hr"),
#     (14400, "4-hr"),
#     (86400, "1-day")
# )
# STRATEGIES = (
#     ("To The Moon", "toTheMoon"),
#     ("Strategy 2", "strategy 2"),
# )
# INSTRUMENTS = (
#     ("ETH", _("Ethereum")),
#     ("DGB", _("DigiByte")),
#     ("XRP", _("Ripple")),
#     ("XMR", _("Monero")),
#     ("LTC", _("LiteCoin")),
#     ("LSK", _("LISK")),
#     ("STEEM", _("STEEM"))
# )
# MODES = (
#     ("backtest", _("Backtest")),
#     ("livetest", _("Live Backtest")),
#     ("live", _("Live"))
# )
#     BUY = 0
#     SELL = 1
# ORDER_TYPES = (
#     (OrderType.BUY, 'buy'),
#     (OrderType.SELL, 'sell')
# )
# OPEN, CANCELLED, PROCESSED = 'open', 'cancelled', 'processed'
# ORDER_STATES = (
#     (OPEN, _('open')),
#     (CANCELLED, _('cancelled')),
#     (PROCESSED, _('processed'))
# )
# SMA, EMA, RSI = 'sma', 'ema', 'rsi'
# INDICATORS = (
#     (SMA, _('sma')),
#     (EMA, _('ema')),
#     (RSI, _('rsi'))
# )
# class OrderType(object):
# 
# Path: crumpet/profiles/fields.py
# class PriceField(models.DecimalField):
#     def __init__(self, max_digits=30, decimal_places=2, default=0, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          default=default,
#                          **kwargs)
# 
# class PercentField(models.DecimalField):
#     def __init__(self, max_digits=8, decimal_places=3, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          **kwargs)
# 
# class AmountField(models.DecimalField):
#     def __init__(self, max_digits=30, decimal_places=8, default=0, **kwargs):
#         super().__init__(max_digits=max_digits,
#                          decimal_places=decimal_places,
#                          default=default,
#                          **kwargs)
# 
# Path: crumpet/profiles/models.py
# class UserAccount(models.Model):
#     """User profile"""
#     user = models.OneToOneField(
#         settings.AUTH_USER_MODEL,
#         related_name="user_account"
#     )
#     exchange = models.CharField(
#         verbose_name="Crypto Exchanges",
#         choices=constants.CRYPTO_EXCHANGES,
#         default=constants.CRYPTO_EXCHANGES[0][0],
#         max_length=30
#     )
#     api_key = models.CharField(max_length=255, blank=True)
#     api_secret = models.CharField(max_length=255, blank=True)
#     created = models.DateTimeField(auto_now_add=True)
#     updated = models.DateTimeField(auto_now=True)
# 
#     class Meta:
#         verbose_name = "User Account"
# 
#     def __str__(self):
#         return u"%s %s" % (self.user.first_name, self.user.last_name)


# Path: crumpet/models.py
from datetime import datetime
from allauth.account.signals import user_signed_up
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from crumpet.profiles import constants
from crumpet.profiles.fields import PriceField, PercentField, AmountField
from crumpet.profiles.models import UserAccount





@python_2_unicode_compatible
class TradingStrategyProfile(models.Model):
    """Base trading strategy configuration models class."""
    name = models.CharField(max_length=100)
    note = models.CharField(max_length=255, blank=True)
    account = models.ForeignKey(UserAccount)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)


@python_2_unicode_compatible
class FixedStrategyProfile(TradingStrategyProfile):
    """Configuration for fixed trading strategy."""
    buy = PriceField()

    sell = PriceField()