Merge branch 'develop' into backtest_live_models
This commit is contained in:
commit
3c002ff752
@ -284,7 +284,7 @@ def load_backtest_data(filename: Union[Path, str], strategy: Optional[str] = Non
|
|||||||
df['enter_tag'] = df['buy_tag']
|
df['enter_tag'] = df['buy_tag']
|
||||||
df = df.drop(['buy_tag'], axis=1)
|
df = df.drop(['buy_tag'], axis=1)
|
||||||
if 'orders' not in df.columns:
|
if 'orders' not in df.columns:
|
||||||
df.loc[:, 'orders'] = None
|
df['orders'] = None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# old format - only with lists.
|
# old format - only with lists.
|
||||||
@ -341,9 +341,9 @@ def trade_list_to_dataframe(trades: List[LocalTrade]) -> pd.DataFrame:
|
|||||||
"""
|
"""
|
||||||
df = pd.DataFrame.from_records([t.to_json(True) for t in trades], columns=BT_DATA_COLUMNS)
|
df = pd.DataFrame.from_records([t.to_json(True) for t in trades], columns=BT_DATA_COLUMNS)
|
||||||
if len(df) > 0:
|
if len(df) > 0:
|
||||||
df.loc[:, 'close_date'] = pd.to_datetime(df['close_date'], utc=True)
|
df['close_date'] = pd.to_datetime(df['close_date'], utc=True)
|
||||||
df.loc[:, 'open_date'] = pd.to_datetime(df['open_date'], utc=True)
|
df['open_date'] = pd.to_datetime(df['open_date'], utc=True)
|
||||||
df.loc[:, 'close_rate'] = df['close_rate'].astype('float64')
|
df['close_rate'] = df['close_rate'].astype('float64')
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class IDataHandler(ABC):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def ohlcv_load(self, pair, timeframe: str,
|
def ohlcv_load(self, pair, timeframe: str,
|
||||||
candle_type: CandleType,
|
candle_type: CandleType, *,
|
||||||
timerange: Optional[TimeRange] = None,
|
timerange: Optional[TimeRange] = None,
|
||||||
fill_missing: bool = True,
|
fill_missing: bool = True,
|
||||||
drop_incomplete: bool = True,
|
drop_incomplete: bool = True,
|
||||||
|
@ -4485,6 +4485,120 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"BTCUSDT_221230": [
|
||||||
|
{
|
||||||
|
"tier": 1.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 0.0,
|
||||||
|
"maxNotional": 375000.0,
|
||||||
|
"maintenanceMarginRate": 0.02,
|
||||||
|
"maxLeverage": 25.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "1",
|
||||||
|
"initialLeverage": "25",
|
||||||
|
"notionalCap": "375000",
|
||||||
|
"notionalFloor": "0",
|
||||||
|
"maintMarginRatio": "0.02",
|
||||||
|
"cum": "0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 2.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 375000.0,
|
||||||
|
"maxNotional": 2000000.0,
|
||||||
|
"maintenanceMarginRate": 0.05,
|
||||||
|
"maxLeverage": 10.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "2",
|
||||||
|
"initialLeverage": "10",
|
||||||
|
"notionalCap": "2000000",
|
||||||
|
"notionalFloor": "375000",
|
||||||
|
"maintMarginRatio": "0.05",
|
||||||
|
"cum": "11250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 3.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 2000000.0,
|
||||||
|
"maxNotional": 4000000.0,
|
||||||
|
"maintenanceMarginRate": 0.1,
|
||||||
|
"maxLeverage": 5.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "3",
|
||||||
|
"initialLeverage": "5",
|
||||||
|
"notionalCap": "4000000",
|
||||||
|
"notionalFloor": "2000000",
|
||||||
|
"maintMarginRatio": "0.1",
|
||||||
|
"cum": "111250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 4.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 4000000.0,
|
||||||
|
"maxNotional": 10000000.0,
|
||||||
|
"maintenanceMarginRate": 0.125,
|
||||||
|
"maxLeverage": 4.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "4",
|
||||||
|
"initialLeverage": "4",
|
||||||
|
"notionalCap": "10000000",
|
||||||
|
"notionalFloor": "4000000",
|
||||||
|
"maintMarginRatio": "0.125",
|
||||||
|
"cum": "211250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 5.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 10000000.0,
|
||||||
|
"maxNotional": 20000000.0,
|
||||||
|
"maintenanceMarginRate": 0.15,
|
||||||
|
"maxLeverage": 3.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "5",
|
||||||
|
"initialLeverage": "3",
|
||||||
|
"notionalCap": "20000000",
|
||||||
|
"notionalFloor": "10000000",
|
||||||
|
"maintMarginRatio": "0.15",
|
||||||
|
"cum": "461250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 6.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 20000000.0,
|
||||||
|
"maxNotional": 40000000.0,
|
||||||
|
"maintenanceMarginRate": 0.25,
|
||||||
|
"maxLeverage": 2.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "6",
|
||||||
|
"initialLeverage": "2",
|
||||||
|
"notionalCap": "40000000",
|
||||||
|
"notionalFloor": "20000000",
|
||||||
|
"maintMarginRatio": "0.25",
|
||||||
|
"cum": "2461250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 7.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 40000000.0,
|
||||||
|
"maxNotional": 400000000.0,
|
||||||
|
"maintenanceMarginRate": 0.5,
|
||||||
|
"maxLeverage": 1.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "7",
|
||||||
|
"initialLeverage": "1",
|
||||||
|
"notionalCap": "400000000",
|
||||||
|
"notionalFloor": "40000000",
|
||||||
|
"maintMarginRatio": "0.5",
|
||||||
|
"cum": "1.246125E7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"BTS/USDT": [
|
"BTS/USDT": [
|
||||||
{
|
{
|
||||||
"tier": 1.0,
|
"tier": 1.0,
|
||||||
@ -5759,6 +5873,104 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"CVX/USDT": [
|
||||||
|
{
|
||||||
|
"tier": 1.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 0.0,
|
||||||
|
"maxNotional": 5000.0,
|
||||||
|
"maintenanceMarginRate": 0.01,
|
||||||
|
"maxLeverage": 25.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "1",
|
||||||
|
"initialLeverage": "25",
|
||||||
|
"notionalCap": "5000",
|
||||||
|
"notionalFloor": "0",
|
||||||
|
"maintMarginRatio": "0.01",
|
||||||
|
"cum": "0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 2.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 5000.0,
|
||||||
|
"maxNotional": 25000.0,
|
||||||
|
"maintenanceMarginRate": 0.025,
|
||||||
|
"maxLeverage": 20.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "2",
|
||||||
|
"initialLeverage": "20",
|
||||||
|
"notionalCap": "25000",
|
||||||
|
"notionalFloor": "5000",
|
||||||
|
"maintMarginRatio": "0.025",
|
||||||
|
"cum": "75.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 3.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 25000.0,
|
||||||
|
"maxNotional": 100000.0,
|
||||||
|
"maintenanceMarginRate": 0.05,
|
||||||
|
"maxLeverage": 10.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "3",
|
||||||
|
"initialLeverage": "10",
|
||||||
|
"notionalCap": "100000",
|
||||||
|
"notionalFloor": "25000",
|
||||||
|
"maintMarginRatio": "0.05",
|
||||||
|
"cum": "700.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 4.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 100000.0,
|
||||||
|
"maxNotional": 250000.0,
|
||||||
|
"maintenanceMarginRate": 0.1,
|
||||||
|
"maxLeverage": 5.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "4",
|
||||||
|
"initialLeverage": "5",
|
||||||
|
"notionalCap": "250000",
|
||||||
|
"notionalFloor": "100000",
|
||||||
|
"maintMarginRatio": "0.1",
|
||||||
|
"cum": "5700.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 5.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 250000.0,
|
||||||
|
"maxNotional": 1000000.0,
|
||||||
|
"maintenanceMarginRate": 0.125,
|
||||||
|
"maxLeverage": 2.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "5",
|
||||||
|
"initialLeverage": "2",
|
||||||
|
"notionalCap": "1000000",
|
||||||
|
"notionalFloor": "250000",
|
||||||
|
"maintMarginRatio": "0.125",
|
||||||
|
"cum": "11950.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 6.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 1000000.0,
|
||||||
|
"maxNotional": 5000000.0,
|
||||||
|
"maintenanceMarginRate": 0.5,
|
||||||
|
"maxLeverage": 1.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "6",
|
||||||
|
"initialLeverage": "1",
|
||||||
|
"notionalCap": "5000000",
|
||||||
|
"notionalFloor": "1000000",
|
||||||
|
"maintMarginRatio": "0.5",
|
||||||
|
"cum": "386950.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"DAR/USDT": [
|
"DAR/USDT": [
|
||||||
{
|
{
|
||||||
"tier": 1.0,
|
"tier": 1.0,
|
||||||
@ -8105,6 +8317,120 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"ETHUSDT_221230": [
|
||||||
|
{
|
||||||
|
"tier": 1.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 0.0,
|
||||||
|
"maxNotional": 375000.0,
|
||||||
|
"maintenanceMarginRate": 0.02,
|
||||||
|
"maxLeverage": 25.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "1",
|
||||||
|
"initialLeverage": "25",
|
||||||
|
"notionalCap": "375000",
|
||||||
|
"notionalFloor": "0",
|
||||||
|
"maintMarginRatio": "0.02",
|
||||||
|
"cum": "0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 2.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 375000.0,
|
||||||
|
"maxNotional": 2000000.0,
|
||||||
|
"maintenanceMarginRate": 0.05,
|
||||||
|
"maxLeverage": 10.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "2",
|
||||||
|
"initialLeverage": "10",
|
||||||
|
"notionalCap": "2000000",
|
||||||
|
"notionalFloor": "375000",
|
||||||
|
"maintMarginRatio": "0.05",
|
||||||
|
"cum": "11250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 3.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 2000000.0,
|
||||||
|
"maxNotional": 4000000.0,
|
||||||
|
"maintenanceMarginRate": 0.1,
|
||||||
|
"maxLeverage": 5.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "3",
|
||||||
|
"initialLeverage": "5",
|
||||||
|
"notionalCap": "4000000",
|
||||||
|
"notionalFloor": "2000000",
|
||||||
|
"maintMarginRatio": "0.1",
|
||||||
|
"cum": "111250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 4.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 4000000.0,
|
||||||
|
"maxNotional": 10000000.0,
|
||||||
|
"maintenanceMarginRate": 0.125,
|
||||||
|
"maxLeverage": 4.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "4",
|
||||||
|
"initialLeverage": "4",
|
||||||
|
"notionalCap": "10000000",
|
||||||
|
"notionalFloor": "4000000",
|
||||||
|
"maintMarginRatio": "0.125",
|
||||||
|
"cum": "211250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 5.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 10000000.0,
|
||||||
|
"maxNotional": 20000000.0,
|
||||||
|
"maintenanceMarginRate": 0.15,
|
||||||
|
"maxLeverage": 3.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "5",
|
||||||
|
"initialLeverage": "3",
|
||||||
|
"notionalCap": "20000000",
|
||||||
|
"notionalFloor": "10000000",
|
||||||
|
"maintMarginRatio": "0.15",
|
||||||
|
"cum": "461250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 6.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 20000000.0,
|
||||||
|
"maxNotional": 40000000.0,
|
||||||
|
"maintenanceMarginRate": 0.25,
|
||||||
|
"maxLeverage": 2.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "6",
|
||||||
|
"initialLeverage": "2",
|
||||||
|
"notionalCap": "40000000",
|
||||||
|
"notionalFloor": "20000000",
|
||||||
|
"maintMarginRatio": "0.25",
|
||||||
|
"cum": "2461250.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 7.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 40000000.0,
|
||||||
|
"maxNotional": 400000000.0,
|
||||||
|
"maintenanceMarginRate": 0.5,
|
||||||
|
"maxLeverage": 1.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "7",
|
||||||
|
"initialLeverage": "1",
|
||||||
|
"notionalCap": "400000000",
|
||||||
|
"notionalFloor": "40000000",
|
||||||
|
"maintMarginRatio": "0.5",
|
||||||
|
"cum": "1.246125E7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"FIL/BUSD": [
|
"FIL/BUSD": [
|
||||||
{
|
{
|
||||||
"tier": 1.0,
|
"tier": 1.0,
|
||||||
@ -10138,10 +10464,10 @@
|
|||||||
"minNotional": 0.0,
|
"minNotional": 0.0,
|
||||||
"maxNotional": 5000.0,
|
"maxNotional": 5000.0,
|
||||||
"maintenanceMarginRate": 0.01,
|
"maintenanceMarginRate": 0.01,
|
||||||
"maxLeverage": 50.0,
|
"maxLeverage": 25.0,
|
||||||
"info": {
|
"info": {
|
||||||
"bracket": "1",
|
"bracket": "1",
|
||||||
"initialLeverage": "50",
|
"initialLeverage": "25",
|
||||||
"notionalCap": "5000",
|
"notionalCap": "5000",
|
||||||
"notionalFloor": "0",
|
"notionalFloor": "0",
|
||||||
"maintMarginRatio": "0.01",
|
"maintMarginRatio": "0.01",
|
||||||
@ -10216,13 +10542,13 @@
|
|||||||
"tier": 6.0,
|
"tier": 6.0,
|
||||||
"currency": "USDT",
|
"currency": "USDT",
|
||||||
"minNotional": 1000000.0,
|
"minNotional": 1000000.0,
|
||||||
"maxNotional": 30000000.0,
|
"maxNotional": 5000000.0,
|
||||||
"maintenanceMarginRate": 0.5,
|
"maintenanceMarginRate": 0.5,
|
||||||
"maxLeverage": 1.0,
|
"maxLeverage": 1.0,
|
||||||
"info": {
|
"info": {
|
||||||
"bracket": "6",
|
"bracket": "6",
|
||||||
"initialLeverage": "1",
|
"initialLeverage": "1",
|
||||||
"notionalCap": "30000000",
|
"notionalCap": "5000000",
|
||||||
"notionalFloor": "1000000",
|
"notionalFloor": "1000000",
|
||||||
"maintMarginRatio": "0.5",
|
"maintMarginRatio": "0.5",
|
||||||
"cum": "386950.0"
|
"cum": "386950.0"
|
||||||
@ -11389,6 +11715,104 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"LDO/USDT": [
|
||||||
|
{
|
||||||
|
"tier": 1.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 0.0,
|
||||||
|
"maxNotional": 5000.0,
|
||||||
|
"maintenanceMarginRate": 0.01,
|
||||||
|
"maxLeverage": 25.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "1",
|
||||||
|
"initialLeverage": "25",
|
||||||
|
"notionalCap": "5000",
|
||||||
|
"notionalFloor": "0",
|
||||||
|
"maintMarginRatio": "0.01",
|
||||||
|
"cum": "0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 2.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 5000.0,
|
||||||
|
"maxNotional": 25000.0,
|
||||||
|
"maintenanceMarginRate": 0.025,
|
||||||
|
"maxLeverage": 20.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "2",
|
||||||
|
"initialLeverage": "20",
|
||||||
|
"notionalCap": "25000",
|
||||||
|
"notionalFloor": "5000",
|
||||||
|
"maintMarginRatio": "0.025",
|
||||||
|
"cum": "75.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 3.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 25000.0,
|
||||||
|
"maxNotional": 100000.0,
|
||||||
|
"maintenanceMarginRate": 0.05,
|
||||||
|
"maxLeverage": 10.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "3",
|
||||||
|
"initialLeverage": "10",
|
||||||
|
"notionalCap": "100000",
|
||||||
|
"notionalFloor": "25000",
|
||||||
|
"maintMarginRatio": "0.05",
|
||||||
|
"cum": "700.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 4.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 100000.0,
|
||||||
|
"maxNotional": 250000.0,
|
||||||
|
"maintenanceMarginRate": 0.1,
|
||||||
|
"maxLeverage": 5.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "4",
|
||||||
|
"initialLeverage": "5",
|
||||||
|
"notionalCap": "250000",
|
||||||
|
"notionalFloor": "100000",
|
||||||
|
"maintMarginRatio": "0.1",
|
||||||
|
"cum": "5700.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 5.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 250000.0,
|
||||||
|
"maxNotional": 1000000.0,
|
||||||
|
"maintenanceMarginRate": 0.125,
|
||||||
|
"maxLeverage": 2.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "5",
|
||||||
|
"initialLeverage": "2",
|
||||||
|
"notionalCap": "1000000",
|
||||||
|
"notionalFloor": "250000",
|
||||||
|
"maintMarginRatio": "0.125",
|
||||||
|
"cum": "11950.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tier": 6.0,
|
||||||
|
"currency": "USDT",
|
||||||
|
"minNotional": 1000000.0,
|
||||||
|
"maxNotional": 5000000.0,
|
||||||
|
"maintenanceMarginRate": 0.5,
|
||||||
|
"maxLeverage": 1.0,
|
||||||
|
"info": {
|
||||||
|
"bracket": "6",
|
||||||
|
"initialLeverage": "1",
|
||||||
|
"notionalCap": "5000000",
|
||||||
|
"notionalFloor": "1000000",
|
||||||
|
"maintMarginRatio": "0.5",
|
||||||
|
"cum": "386950.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"LEVER/BUSD": [
|
"LEVER/BUSD": [
|
||||||
{
|
{
|
||||||
"tier": 1.0,
|
"tier": 1.0,
|
||||||
|
@ -377,10 +377,10 @@ class Backtesting:
|
|||||||
for col in HEADERS[5:]:
|
for col in HEADERS[5:]:
|
||||||
tag_col = col in ('enter_tag', 'exit_tag')
|
tag_col = col in ('enter_tag', 'exit_tag')
|
||||||
if col in df_analyzed.columns:
|
if col in df_analyzed.columns:
|
||||||
df_analyzed.loc[:, col] = df_analyzed.loc[:, col].replace(
|
df_analyzed[col] = df_analyzed.loc[:, col].replace(
|
||||||
[nan], [0 if not tag_col else None]).shift(1)
|
[nan], [0 if not tag_col else None]).shift(1)
|
||||||
elif not df_analyzed.empty:
|
elif not df_analyzed.empty:
|
||||||
df_analyzed.loc[:, col] = 0 if not tag_col else None
|
df_analyzed[col] = 0 if not tag_col else None
|
||||||
|
|
||||||
df_analyzed = df_analyzed.drop(df_analyzed.head(1).index)
|
df_analyzed = df_analyzed.drop(df_analyzed.head(1).index)
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ def generate_tag_metrics(tag_type: str,
|
|||||||
tabular_data = []
|
tabular_data = []
|
||||||
|
|
||||||
if tag_type in results.columns:
|
if tag_type in results.columns:
|
||||||
for tag, count in results[tag_type].value_counts().iteritems():
|
for tag, count in results[tag_type].value_counts().items():
|
||||||
result = results[results[tag_type] == tag]
|
result = results[results[tag_type] == tag]
|
||||||
if skip_nan and result['profit_abs'].isnull().all():
|
if skip_nan and result['profit_abs'].isnull().all():
|
||||||
continue
|
continue
|
||||||
@ -199,7 +199,7 @@ def generate_exit_reason_stats(max_open_trades: int, results: DataFrame) -> List
|
|||||||
"""
|
"""
|
||||||
tabular_data = []
|
tabular_data = []
|
||||||
|
|
||||||
for reason, count in results['exit_reason'].value_counts().iteritems():
|
for reason, count in results['exit_reason'].value_counts().items():
|
||||||
result = results.loc[results['exit_reason'] == reason]
|
result = results.loc[results['exit_reason'] == reason]
|
||||||
|
|
||||||
profit_mean = result['profit_ratio'].mean()
|
profit_mean = result['profit_ratio'].mean()
|
||||||
@ -361,7 +361,7 @@ def generate_daily_stats(results: DataFrame) -> Dict[str, Any]:
|
|||||||
winning_days = sum(daily_profit > 0)
|
winning_days = sum(daily_profit > 0)
|
||||||
draw_days = sum(daily_profit == 0)
|
draw_days = sum(daily_profit == 0)
|
||||||
losing_days = sum(daily_profit < 0)
|
losing_days = sum(daily_profit < 0)
|
||||||
daily_profit_list = [(str(idx.date()), val) for idx, val in daily_profit.iteritems()]
|
daily_profit_list = [(str(idx.date()), val) for idx, val in daily_profit.items()]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'backtest_best_day': best_rel,
|
'backtest_best_day': best_rel,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
numpy==1.23.3
|
numpy==1.23.3
|
||||||
pandas==1.5.0
|
pandas==1.5.0; platform_machine != 'armv7l'
|
||||||
|
# Piwheels doesn't have 1.5.0 yet.
|
||||||
|
pandas==1.4.3; platform_machine == 'armv7l'
|
||||||
pandas-ta==0.3.14b
|
pandas-ta==0.3.14b
|
||||||
|
|
||||||
ccxt==1.93.98
|
ccxt==1.93.98
|
||||||
@ -21,7 +23,7 @@ jinja2==3.1.2
|
|||||||
tables==3.7.0
|
tables==3.7.0
|
||||||
blosc==1.10.6
|
blosc==1.10.6
|
||||||
joblib==1.2.0
|
joblib==1.2.0
|
||||||
pyarrow==9.0.0
|
pyarrow==9.0.0; platform_machine != 'armv7l'
|
||||||
|
|
||||||
# find first, C search in arrays
|
# find first, C search in arrays
|
||||||
py_find_1st==1.1.5
|
py_find_1st==1.1.5
|
||||||
|
2
setup.py
2
setup.py
@ -73,7 +73,7 @@ setup(
|
|||||||
'tables',
|
'tables',
|
||||||
'blosc',
|
'blosc',
|
||||||
'joblib',
|
'joblib',
|
||||||
'pyarrow',
|
'pyarrow; platform_machine != "armv7l"',
|
||||||
'fastapi',
|
'fastapi',
|
||||||
'uvicorn',
|
'uvicorn',
|
||||||
'psutil',
|
'psutil',
|
||||||
|
@ -275,7 +275,7 @@ def test_create_cum_profit1(testdatadir):
|
|||||||
filename = testdatadir / "backtest_results/backtest-result_new.json"
|
filename = testdatadir / "backtest_results/backtest-result_new.json"
|
||||||
bt_data = load_backtest_data(filename)
|
bt_data = load_backtest_data(filename)
|
||||||
# Move close-time to "off" the candle, to make sure the logic still works
|
# Move close-time to "off" the candle, to make sure the logic still works
|
||||||
bt_data.loc[:, 'close_date'] = bt_data.loc[:, 'close_date'] + DateOffset(seconds=20)
|
bt_data['close_date'] = bt_data.loc[:, 'close_date'] + DateOffset(seconds=20)
|
||||||
timerange = TimeRange.parse_timerange("20180110-20180112")
|
timerange = TimeRange.parse_timerange("20180110-20180112")
|
||||||
|
|
||||||
df = load_pair_history(pair="TRX/BTC", timeframe='5m',
|
df = load_pair_history(pair="TRX/BTC", timeframe='5m',
|
||||||
|
@ -839,7 +839,7 @@ def test_backtest_trim_no_data_left(default_conf, fee, mocker, testdatadir) -> N
|
|||||||
data = history.load_data(datadir=testdatadir, timeframe='5m', pairs=['UNITTEST/BTC'],
|
data = history.load_data(datadir=testdatadir, timeframe='5m', pairs=['UNITTEST/BTC'],
|
||||||
timerange=timerange)
|
timerange=timerange)
|
||||||
df = data['UNITTEST/BTC']
|
df = data['UNITTEST/BTC']
|
||||||
df.loc[:, 'date'] = df.loc[:, 'date'] - timedelta(days=1)
|
df['date'] = df.loc[:, 'date'] - timedelta(days=1)
|
||||||
# Trimming 100 candles, so after 2nd trimming, no candle is left.
|
# Trimming 100 candles, so after 2nd trimming, no candle is left.
|
||||||
df = df.iloc[:100]
|
df = df.iloc[:100]
|
||||||
data['XRP/USDT'] = df
|
data['XRP/USDT'] = df
|
||||||
|
@ -622,10 +622,10 @@ def test_VolumePairList_range(mocker, whitelist_conf, shitcoinmarkets, tickers,
|
|||||||
|
|
||||||
# create candles for high volume with all candles high volume, but very low price.
|
# create candles for high volume with all candles high volume, but very low price.
|
||||||
ohlcv_history_high_volume = ohlcv_history.copy()
|
ohlcv_history_high_volume = ohlcv_history.copy()
|
||||||
ohlcv_history_high_volume.loc[:, 'volume'] = 10
|
ohlcv_history_high_volume['volume'] = 10
|
||||||
ohlcv_history_high_volume.loc[:, 'low'] = ohlcv_history_high_volume.loc[:, 'low'] * 0.01
|
ohlcv_history_high_volume['low'] = ohlcv_history_high_volume.loc[:, 'low'] * 0.01
|
||||||
ohlcv_history_high_volume.loc[:, 'high'] = ohlcv_history_high_volume.loc[:, 'high'] * 0.01
|
ohlcv_history_high_volume['high'] = ohlcv_history_high_volume.loc[:, 'high'] * 0.01
|
||||||
ohlcv_history_high_volume.loc[:, 'close'] = ohlcv_history_high_volume.loc[:, 'close'] * 0.01
|
ohlcv_history_high_volume['close'] = ohlcv_history_high_volume.loc[:, 'close'] * 0.01
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.ftx.Ftx.market_is_tradable', return_value=True)
|
mocker.patch('freqtrade.exchange.ftx.Ftx.market_is_tradable', return_value=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user