Merge branch 'develop' into feat_readjust_entry

This commit is contained in:
eSeR1805 2022-04-18 21:22:19 +03:00
commit cea4f663d5
No known key found for this signature in database
GPG Key ID: BA53686259B46936
9 changed files with 4412 additions and 4412 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2137,8 +2137,8 @@ class Exchange:
def parse_leverage_tier(self, tier) -> Dict:
info = tier.get('info', {})
return {
'min': tier['notionalFloor'],
'max': tier['notionalCap'],
'min': tier['minNotional'],
'max': tier['maxNotional'],
'mmr': tier['maintenanceMarginRate'],
'lev': tier['maxLeverage'],
'maintAmt': float(info['cum']) if 'cum' in info else None,

View File

@ -19,13 +19,13 @@ isort==5.10.1
time-machine==2.6.0
# Convert jupyter notebooks to markdown documents
nbconvert==6.4.5
nbconvert==6.5.0
# mypy types
types-cachetools==5.0.0
types-cachetools==5.0.1
types-filelock==3.2.5
types-requests==2.27.16
types-tabulate==0.8.6
types-requests==2.27.19
types-tabulate==0.8.7
# Extensions to datetime library
types-python-dateutil==2.8.10
types-python-dateutil==2.8.11

View File

@ -2,7 +2,7 @@ numpy==1.22.3
pandas==1.4.2
pandas-ta==0.3.14b
ccxt==1.78.62
ccxt==1.79.81
# Pin cryptography for now due to rust build errors with piwheels
cryptography==36.0.2
aiohttp==3.8.1
@ -31,7 +31,7 @@ python-rapidjson==1.6
sdnotify==0.3.2
# API Server
fastapi==0.75.1
fastapi==0.75.2
uvicorn==0.17.6
pyjwt==2.3.0
aiofiles==0.8.0

View File

@ -42,7 +42,7 @@ setup(
],
install_requires=[
# from requirements.txt
'ccxt>=1.77.29',
'ccxt>=1.79.69',
'SQLAlchemy',
'python-telegram-bot>=13.4',
'arrow>=0.17.0',

View File

@ -169,90 +169,90 @@ def test_fill_leverage_tiers_binance(default_conf, mocker):
'ADA/BUSD': [
{
"tier": 1,
"notionalFloor": 0,
"notionalCap": 100000,
"minNotional": 0,
"maxNotional": 100000,
"maintenanceMarginRate": 0.025,
"maxLeverage": 20,
"info": {
"bracket": "1",
"initialLeverage": "20",
"notionalCap": "100000",
"notionalFloor": "0",
"maxNotional": "100000",
"minNotional": "0",
"maintMarginRatio": "0.025",
"cum": "0.0"
}
},
{
"tier": 2,
"notionalFloor": 100000,
"notionalCap": 500000,
"minNotional": 100000,
"maxNotional": 500000,
"maintenanceMarginRate": 0.05,
"maxLeverage": 10,
"info": {
"bracket": "2",
"initialLeverage": "10",
"notionalCap": "500000",
"notionalFloor": "100000",
"maxNotional": "500000",
"minNotional": "100000",
"maintMarginRatio": "0.05",
"cum": "2500.0"
}
},
{
"tier": 3,
"notionalFloor": 500000,
"notionalCap": 1000000,
"minNotional": 500000,
"maxNotional": 1000000,
"maintenanceMarginRate": 0.1,
"maxLeverage": 5,
"info": {
"bracket": "3",
"initialLeverage": "5",
"notionalCap": "1000000",
"notionalFloor": "500000",
"maxNotional": "1000000",
"minNotional": "500000",
"maintMarginRatio": "0.1",
"cum": "27500.0"
}
},
{
"tier": 4,
"notionalFloor": 1000000,
"notionalCap": 2000000,
"minNotional": 1000000,
"maxNotional": 2000000,
"maintenanceMarginRate": 0.15,
"maxLeverage": 3,
"info": {
"bracket": "4",
"initialLeverage": "3",
"notionalCap": "2000000",
"notionalFloor": "1000000",
"maxNotional": "2000000",
"minNotional": "1000000",
"maintMarginRatio": "0.15",
"cum": "77500.0"
}
},
{
"tier": 5,
"notionalFloor": 2000000,
"notionalCap": 5000000,
"minNotional": 2000000,
"maxNotional": 5000000,
"maintenanceMarginRate": 0.25,
"maxLeverage": 2,
"info": {
"bracket": "5",
"initialLeverage": "2",
"notionalCap": "5000000",
"notionalFloor": "2000000",
"maxNotional": "5000000",
"minNotional": "2000000",
"maintMarginRatio": "0.25",
"cum": "277500.0"
}
},
{
"tier": 6,
"notionalFloor": 5000000,
"notionalCap": 30000000,
"minNotional": 5000000,
"maxNotional": 30000000,
"maintenanceMarginRate": 0.5,
"maxLeverage": 1,
"info": {
"bracket": "6",
"initialLeverage": "1",
"notionalCap": "30000000",
"notionalFloor": "5000000",
"maxNotional": "30000000",
"minNotional": "5000000",
"maintMarginRatio": "0.5",
"cum": "1527500.0"
}
@ -261,105 +261,105 @@ def test_fill_leverage_tiers_binance(default_conf, mocker):
"ZEC/USDT": [
{
"tier": 1,
"notionalFloor": 0,
"notionalCap": 50000,
"minNotional": 0,
"maxNotional": 50000,
"maintenanceMarginRate": 0.01,
"maxLeverage": 50,
"info": {
"bracket": "1",
"initialLeverage": "50",
"notionalCap": "50000",
"notionalFloor": "0",
"maxNotional": "50000",
"minNotional": "0",
"maintMarginRatio": "0.01",
"cum": "0.0"
}
},
{
"tier": 2,
"notionalFloor": 50000,
"notionalCap": 150000,
"minNotional": 50000,
"maxNotional": 150000,
"maintenanceMarginRate": 0.025,
"maxLeverage": 20,
"info": {
"bracket": "2",
"initialLeverage": "20",
"notionalCap": "150000",
"notionalFloor": "50000",
"maxNotional": "150000",
"minNotional": "50000",
"maintMarginRatio": "0.025",
"cum": "750.0"
}
},
{
"tier": 3,
"notionalFloor": 150000,
"notionalCap": 250000,
"minNotional": 150000,
"maxNotional": 250000,
"maintenanceMarginRate": 0.05,
"maxLeverage": 10,
"info": {
"bracket": "3",
"initialLeverage": "10",
"notionalCap": "250000",
"notionalFloor": "150000",
"maxNotional": "250000",
"minNotional": "150000",
"maintMarginRatio": "0.05",
"cum": "4500.0"
}
},
{
"tier": 4,
"notionalFloor": 250000,
"notionalCap": 500000,
"minNotional": 250000,
"maxNotional": 500000,
"maintenanceMarginRate": 0.1,
"maxLeverage": 5,
"info": {
"bracket": "4",
"initialLeverage": "5",
"notionalCap": "500000",
"notionalFloor": "250000",
"maxNotional": "500000",
"minNotional": "250000",
"maintMarginRatio": "0.1",
"cum": "17000.0"
}
},
{
"tier": 5,
"notionalFloor": 500000,
"notionalCap": 1000000,
"minNotional": 500000,
"maxNotional": 1000000,
"maintenanceMarginRate": 0.125,
"maxLeverage": 4,
"info": {
"bracket": "5",
"initialLeverage": "4",
"notionalCap": "1000000",
"notionalFloor": "500000",
"maxNotional": "1000000",
"minNotional": "500000",
"maintMarginRatio": "0.125",
"cum": "29500.0"
}
},
{
"tier": 6,
"notionalFloor": 1000000,
"notionalCap": 2000000,
"minNotional": 1000000,
"maxNotional": 2000000,
"maintenanceMarginRate": 0.25,
"maxLeverage": 2,
"info": {
"bracket": "6",
"initialLeverage": "2",
"notionalCap": "2000000",
"notionalFloor": "1000000",
"maxNotional": "2000000",
"minNotional": "1000000",
"maintMarginRatio": "0.25",
"cum": "154500.0"
}
},
{
"tier": 7,
"notionalFloor": 2000000,
"notionalCap": 30000000,
"minNotional": 2000000,
"maxNotional": 30000000,
"maintenanceMarginRate": 0.5,
"maxLeverage": 1,
"info": {
"bracket": "7",
"initialLeverage": "1",
"notionalCap": "30000000",
"notionalFloor": "2000000",
"maxNotional": "30000000",
"minNotional": "2000000",
"maintMarginRatio": "0.5",
"cum": "654500.0"
}

View File

@ -369,25 +369,25 @@ class TestCCXTExchange():
pair_tiers = leverage_tiers[futures_pair]
assert len(pair_tiers) > 0
oldLeverage = float('inf')
oldMaintenanceMarginRate = oldNotionalFloor = oldNotionalCap = -1
oldMaintenanceMarginRate = oldminNotional = oldmaxNotional = -1
for tier in pair_tiers:
for key in [
'maintenanceMarginRate',
'notionalFloor',
'notionalCap',
'minNotional',
'maxNotional',
'maxLeverage'
]:
assert key in tier
assert tier[key] >= 0.0
assert tier['notionalCap'] > tier['notionalFloor']
assert tier['maxNotional'] > tier['minNotional']
assert tier['maxLeverage'] <= oldLeverage
assert tier['maintenanceMarginRate'] >= oldMaintenanceMarginRate
assert tier['notionalFloor'] > oldNotionalFloor
assert tier['notionalCap'] > oldNotionalCap
assert tier['minNotional'] > oldminNotional
assert tier['maxNotional'] > oldmaxNotional
oldLeverage = tier['maxLeverage']
oldMaintenanceMarginRate = tier['maintenanceMarginRate']
oldNotionalFloor = tier['notionalFloor']
oldNotionalCap = tier['notionalCap']
oldminNotional = tier['minNotional']
oldmaxNotional = tier['maxNotional']
def test_ccxt_dry_run_liquidation_price(self, exchange_futures):
futures, futures_name = exchange_futures

View File

@ -4507,8 +4507,8 @@ def test_load_leverage_tiers(mocker, default_conf, leverage_tiers, exchange_name
'ADA/USDT:USDT': [
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 500,
'minNotional': 0,
'maxNotional': 500,
'maintenanceMarginRate': 0.02,
'maxLeverage': 75,
'info': {
@ -4548,8 +4548,8 @@ def test_load_leverage_tiers(mocker, default_conf, leverage_tiers, exchange_name
'ADA/USDT:USDT': [
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 500,
'minNotional': 0,
'maxNotional': 500,
'maintenanceMarginRate': 0.02,
'maxLeverage': 75,
'info': {
@ -4584,15 +4584,15 @@ def test_parse_leverage_tier(mocker, default_conf):
tier = {
"tier": 1,
"notionalFloor": 0,
"notionalCap": 100000,
"minNotional": 0,
"maxNotional": 100000,
"maintenanceMarginRate": 0.025,
"maxLeverage": 20,
"info": {
"bracket": "1",
"initialLeverage": "20",
"notionalCap": "100000",
"notionalFloor": "0",
"maxNotional": "100000",
"minNotional": "0",
"maintMarginRatio": "0.025",
"cum": "0.0"
}
@ -4608,8 +4608,8 @@ def test_parse_leverage_tier(mocker, default_conf):
tier2 = {
'tier': 1,
'notionalFloor': 0,
'notionalCap': 2000,
'minNotional': 0,
'maxNotional': 2000,
'maintenanceMarginRate': 0.01,
'maxLeverage': 75,
'info': {

View File

@ -19,8 +19,8 @@ def test_get_maintenance_ratio_and_amt_okx(
'ETH/USDT:USDT': [
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 2000,
'minNotional': 0,
'maxNotional': 2000,
'maintenanceMarginRate': 0.01,
'maxLeverage': 75,
'info': {
@ -39,8 +39,8 @@ def test_get_maintenance_ratio_and_amt_okx(
},
{
'tier': 2,
'notionalFloor': 2001,
'notionalCap': 4000,
'minNotional': 2001,
'maxNotional': 4000,
'maintenanceMarginRate': 0.015,
'maxLeverage': 50,
'info': {
@ -59,8 +59,8 @@ def test_get_maintenance_ratio_and_amt_okx(
},
{
'tier': 3,
'notionalFloor': 4001,
'notionalCap': 8000,
'minNotional': 4001,
'maxNotional': 8000,
'maintenanceMarginRate': 0.02,
'maxLeverage': 20,
'info': {
@ -81,8 +81,8 @@ def test_get_maintenance_ratio_and_amt_okx(
'ADA/USDT:USDT': [
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 500,
'minNotional': 0,
'maxNotional': 500,
'maintenanceMarginRate': 0.02,
'maxLeverage': 75,
'info': {
@ -101,8 +101,8 @@ def test_get_maintenance_ratio_and_amt_okx(
},
{
'tier': 2,
'notionalFloor': 501,
'notionalCap': 1000,
'minNotional': 501,
'maxNotional': 1000,
'maintenanceMarginRate': 0.025,
'maxLeverage': 50,
'info': {
@ -121,8 +121,8 @@ def test_get_maintenance_ratio_and_amt_okx(
},
{
'tier': 3,
'notionalFloor': 1001,
'notionalCap': 2000,
'minNotional': 1001,
'maxNotional': 2000,
'maintenanceMarginRate': 0.03,
'maxLeverage': 20,
'info': {
@ -180,8 +180,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
[
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 500,
'minNotional': 0,
'maxNotional': 500,
'maintenanceMarginRate': 0.02,
'maxLeverage': 75,
'info': {
@ -200,8 +200,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
},
{
'tier': 2,
'notionalFloor': 501,
'notionalCap': 1000,
'minNotional': 501,
'maxNotional': 1000,
'maintenanceMarginRate': 0.025,
'maxLeverage': 50,
'info': {
@ -220,8 +220,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
},
{
'tier': 3,
'notionalFloor': 1001,
'notionalCap': 2000,
'minNotional': 1001,
'maxNotional': 2000,
'maintenanceMarginRate': 0.03,
'maxLeverage': 20,
'info': {
@ -242,8 +242,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
[
{
'tier': 1,
'notionalFloor': 0,
'notionalCap': 2000,
'minNotional': 0,
'maxNotional': 2000,
'maintenanceMarginRate': 0.01,
'maxLeverage': 75,
'info': {
@ -262,8 +262,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
},
{
'tier': 2,
'notionalFloor': 2001,
'notionalCap': 4000,
'minNotional': 2001,
'maxNotional': 4000,
'maintenanceMarginRate': 0.015,
'maxLeverage': 50,
'info': {
@ -282,8 +282,8 @@ def test_load_leverage_tiers_okx(default_conf, mocker, markets):
},
{
'tier': 3,
'notionalFloor': 4001,
'notionalCap': 8000,
'minNotional': 4001,
'maxNotional': 8000,
'maintenanceMarginRate': 0.02,
'maxLeverage': 20,
'info': {