All persistence margin tests pass
This commit is contained in:
parent
79d394058f
commit
769f72e5ee
@ -8,6 +8,7 @@ twenty_four = Decimal(24.0)
|
||||
|
||||
|
||||
class InterestMode(Enum):
|
||||
"""Equations to calculate interest"""
|
||||
|
||||
HOURSPERDAY = "HOURSPERDAY"
|
||||
HOURSPER4 = "HOURSPER4" # Hours per 4 hour segment
|
||||
@ -21,4 +22,4 @@ class InterestMode(Enum):
|
||||
elif self.name == "HOURSPER4":
|
||||
return borrowed * rate * (1 + max(0, (hours-four)/four))
|
||||
else:
|
||||
raise OperationalException(f"Leverage not available on this exchange with freqtrade")
|
||||
raise OperationalException("Leverage not available on this exchange with freqtrade")
|
||||
|
@ -6,7 +6,7 @@ from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer, String,
|
||||
from sqlalchemy import (Boolean, Column, DateTime, Enum, Float, ForeignKey, Integer, String,
|
||||
create_engine, desc, func, inspect)
|
||||
from sqlalchemy.exc import NoSuchModuleError
|
||||
from sqlalchemy.orm import Query, declarative_base, relationship, scoped_session, sessionmaker
|
||||
@ -159,7 +159,7 @@ class Order(_DECL_BASE):
|
||||
self.remaining = order.get('remaining', self.remaining)
|
||||
self.cost = order.get('cost', self.cost)
|
||||
self.leverage = order.get('leverage', self.leverage)
|
||||
# TODO-mg: liquidation price? is_short?
|
||||
# TODO-mg: is_short?
|
||||
if 'timestamp' in order and order['timestamp'] is not None:
|
||||
self.order_date = datetime.fromtimestamp(order['timestamp'] / 1000, tz=timezone.utc)
|
||||
|
||||
@ -864,7 +864,7 @@ class Trade(_DECL_BASE, LocalTrade):
|
||||
interest_rate = Column(Float, nullable=False, default=0.0)
|
||||
liquidation_price = Column(Float, nullable=True)
|
||||
is_short = Column(Boolean, nullable=False, default=False)
|
||||
interest_mode = Column(String(100), nullable=True)
|
||||
interest_mode = Column(Enum(InterestMode), nullable=True)
|
||||
# End of margin trading properties
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user