-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from enarjord/v5.5.0_ohlcv
V5.5.0 ohlcv
- Loading branch information
Showing
21 changed files
with
673 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
|
||
:warning: **Use at own risk** :warning: | ||
|
||
v5.4.3 | ||
v5.5.0 | ||
|
||
|
||
## Overview | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import os | ||
|
||
if "NOJIT" not in os.environ: | ||
os.environ["NOJIT"] = "true" | ||
|
||
import traceback | ||
import json | ||
import argparse | ||
import asyncio | ||
from procedures import create_binance_bot, make_get_filepath | ||
from pure_funcs import get_template_live_config, flatten | ||
from njit_funcs import round_dynamic | ||
from time import sleep | ||
import logging | ||
import logging.config | ||
|
||
|
||
async def main(): | ||
logging.basicConfig( | ||
format="%(asctime)s %(levelname)-8s %(message)s", | ||
level=logging.INFO, | ||
datefmt="%Y-%m-%dT%H:%M:%S", | ||
) | ||
parser = argparse.ArgumentParser( | ||
prog="auto profit transfer", | ||
description="automatically transfer percentage of profits from futures wallet to spot wallet", | ||
) | ||
parser.add_argument("user", type=str, help="user/account_name defined in api-keys.json") | ||
parser.add_argument( | ||
"-p", | ||
"--percentage", | ||
type=float, | ||
required=False, | ||
default=0.5, | ||
dest="percentage", | ||
help="per uno, i.e. 0.02==2%. default=0.5", | ||
) | ||
args = parser.parse_args() | ||
config = get_template_live_config() | ||
config["user"] = args.user | ||
config["symbol"] = "BTCUSDT" # dummy symbol | ||
config["market_type"] = "futures" | ||
bot = await create_binance_bot(config) | ||
transfer_log_fpath = make_get_filepath( | ||
os.path.join("logs", f"automatic_profit_transfer_log_{config['user']}.json") | ||
) | ||
try: | ||
already_transferred_ids = set(json.load(open(transfer_log_fpath))) | ||
logging.info(f"loaded already transferred IDs: {transfer_log_fpath}") | ||
except: | ||
already_transferred_ids = set() | ||
logging.info(f"no previous transfers to load") | ||
while True: | ||
now = (await bot.public_get(bot.endpoints["time"]))["serverTime"] | ||
try: | ||
income = await bot.get_all_income(start_time=now - 1000 * 60 * 60 * 24) | ||
except Exception as e: | ||
logging.error(f"failed fetching income {e}") | ||
traceback.print_exc() | ||
income = [] | ||
income = [e for e in income if e["transaction_id"] not in already_transferred_ids] | ||
profit = sum([e["income"] for e in income]) | ||
to_transfer = round_dynamic(profit * args.percentage, 4) | ||
if to_transfer > 0: | ||
try: | ||
transferred = await bot.private_post( | ||
bot.endpoints["futures_transfer"], | ||
{"asset": "USDT", "amount": to_transfer, "type": 2}, | ||
base_endpoint=bot.spot_base_endpoint, | ||
) | ||
logging.info(f"income: {profit} transferred {to_transfer} USDT") | ||
already_transferred_ids.update([e["transaction_id"] for e in income]) | ||
json.dump(list(already_transferred_ids), open(transfer_log_fpath, "w")) | ||
except Exception as e: | ||
logging.error(f"failed transferring {e}") | ||
traceback.print_exc() | ||
else: | ||
logging.info("nothing to transfer") | ||
sleep(60 * 60) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 27 additions & 27 deletions
54
configs/live/recursive_grid_mode_auto_unstuck_enabled.example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
{"config_name": "multi_80symbols_2021-05-01to2022-01-26_recursive_grid_auto_unstuck_enabled", | ||
{"config_name": "recursive_grid_126_symbols_285days", | ||
"logging_level": 0, | ||
"long": {"auto_unstuck_ema_dist": 0.04533399066282969, | ||
"auto_unstuck_wallet_exposure_threshold": 0.5089280603807499, | ||
"ddown_factor": 0.1945371972359446, | ||
"ema_span_0": 2344.941992440916, | ||
"ema_span_1": 3569.8635166063227, | ||
"long": {"auto_unstuck_ema_dist": 0.0008943228930055836, | ||
"auto_unstuck_wallet_exposure_threshold": 0.12672073730468353, | ||
"ddown_factor": 0.09916040750089808, | ||
"ema_span_0": 789.7249165793291, | ||
"ema_span_1": 1440, | ||
"enabled": true, | ||
"initial_eprice_ema_dist": 0.05, | ||
"initial_qty_pct": 0.011188848380606475, | ||
"markup_range": 0.0466190685279263, | ||
"min_markup": 0.03771922872466367, | ||
"n_close_orders": 11, | ||
"rentry_pprice_dist": 0.012851520514242834, | ||
"rentry_pprice_dist_wallet_exposure_weighting": 30.493849924344417, | ||
"wallet_exposure_limit": 0.05}, | ||
"short": {"auto_unstuck_ema_dist": 0.014817833487147757, | ||
"auto_unstuck_wallet_exposure_threshold": 0.6984580115288681, | ||
"ddown_factor": 2.346969025866142, | ||
"ema_span_0": 4677.572747718445, | ||
"ema_span_1": 4313.626811916282, | ||
"initial_eprice_ema_dist": 0, | ||
"initial_qty_pct": 0.01, | ||
"markup_range": 0.04699693966985813, | ||
"min_markup": 0.04298063900843883, | ||
"n_close_orders": 10, | ||
"rentry_pprice_dist": 0.02209348612738956, | ||
"rentry_pprice_dist_wallet_exposure_weighting": 11.95394791078704, | ||
"wallet_exposure_limit": 0.1}, | ||
"short": {"auto_unstuck_ema_dist": 0.02360107918060952, | ||
"auto_unstuck_wallet_exposure_threshold": 0.8696017484288251, | ||
"ddown_factor": 2.8578807917477422, | ||
"ema_span_0": 1845.9622772519149, | ||
"ema_span_1": 2220.149357438459, | ||
"enabled": false, | ||
"initial_eprice_ema_dist": -0.04258632696780627, | ||
"initial_qty_pct": 0.09718074802124348, | ||
"markup_range": 0.027535790140754787, | ||
"min_markup": 0.01832088726601801, | ||
"n_close_orders": 8, | ||
"rentry_pprice_dist": 0.039694739209284916, | ||
"rentry_pprice_dist_wallet_exposure_weighting": 61.012162690905335, | ||
"wallet_exposure_limit": 0.05}} | ||
"initial_eprice_ema_dist": -0.08285630558057448, | ||
"initial_qty_pct": 0.030171219081039008, | ||
"markup_range": 0.023949596946105916, | ||
"min_markup": 0.03925744129630296, | ||
"n_close_orders": 5, | ||
"rentry_pprice_dist": 0.024734943307523287, | ||
"rentry_pprice_dist_wallet_exposure_weighting": 54.338880623212155, | ||
"wallet_exposure_limit": 0.1}} |
Oops, something went wrong.