示例#1
0
    def run(self):
        # for i in range(100):
        #     print(i)
        #     val_cb = f'2021&{i}&{i}'
        #     self._cb(val_cb)
        #     time.sleep(1)

        history = []
        for manager in backtest(datetime(2021, 1, 1), datetime.now()):
            btc_value = manager.collate_coins("BTC")
            bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
            history.append((btc_value, bridge_value))
            btc_diff = round((btc_value - history[0][0]) / history[0][0], 3)
            bridge_diff = round((bridge_value - history[0][1]) / history[0][1],
                                3)
            val_cb = f'{manager.datetime}&{btc_value:.3f}&{bridge_value:.3f}'
            print("------")
            print("TIME:", manager.datetime)
            print("BALANCES:", manager.balances)
            print("BTC VALUE:", btc_value, f"({btc_diff}%)")
            print(f"{manager.config.BRIDGE.symbol} VALUE:", bridge_value,
                  f"({bridge_diff}%)")
            print("------")
            self._cb(val_cb)
            if self.stop:
                break
示例#2
0
from datetime import datetime

from binance_trade_bot import backtest

if __name__ == "__main__":
    history = []
    for manager in backtest(datetime(2021, 1, 1), datetime.now()):
        btc_value = manager.collate_coins("BTC")
        bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
        history.append((btc_value, bridge_value))
        btc_diff = round((btc_value - history[0][0]) / history[0][0] * 100, 3)
        bridge_diff = round(
            (bridge_value - history[0][1]) / history[0][1] * 100, 3)
        print("------")
        print("TIME:", manager.datetime)
        print("BALANCES:", manager.balances)
        print("BTC VALUE:", btc_value, f"({btc_diff}%)")
        print(f"{manager.config.BRIDGE.symbol} VALUE:", bridge_value,
              f"({bridge_diff}%)")
        print("------")
from datetime import datetime

from binance_trade_bot import backtest

if __name__ == "__main__":
    history = []
    for manager in backtest(datetime(2021, 5, 1),
                            datetime(2021, 6, 1),
                            30,
                            50,
                            starting_coin="ETH"):
        btc_value = manager.collate_coins("BTC")
        bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
        history.append((btc_value, bridge_value))
        btc_diff = round((btc_value - history[0][0]) / history[0][0], 3)
        bridge_diff = round((bridge_value - history[0][1]) / history[0][1], 3)
        print("------")
        print("TIME:", manager.datetime)
        print("BALANCES:", manager.balances)
        print("BTC VALUE:", btc_value, f"({btc_diff})")
        print(f"{manager.config.BRIDGE.symbol} VALUE:", bridge_value,
              f"({bridge_diff})")
        print("------")

        # 5/1 -- 2661
        # 5/31 -- 2440
示例#4
0
from datetime import datetime
import time

from matplotlib import pyplot as plt
import numpy as np

from binance_trade_bot import backtest

if __name__ == "__main__":
    history = []
    diff = []
    start = datetime(2021, 6, 10, 20, 0)
    end = datetime(2021, 6, 26, 23, 50)
    for manager in backtest(start, end):
        # time.sleep(1)
        # btc_value = manager.collate_coins("BTC")
        bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
        # history.append((btc_value, bridge_value))
        history.append((bridge_value))
        # btc_diff = round((btc_value - history[0][0]) / history[0][0], 3)
        # bridge_diff = round((bridge_value - history[0][1]) / history[0][1], 3)
        bridge_diff = round((bridge_value - history[0]) / history[0], 3) * 100
        diff.append(bridge_diff)
        print("------")
        print("TIME:", manager.datetime)
        print("BALANCES:", manager.balances)
        # print("BTC VALUE:", btc_value, f"({btc_diff}%)")
        print(f"{manager.config.BRIDGE.symbol} VALUE:", bridge_value, f"({bridge_diff}%)")
        print("------")
        # time.sleep(3)
示例#5
0
from datetime import datetime

from binance_trade_bot import backtest

if __name__ == "__main__":
    history = []
    start_time = datetime(2021, 6, 1, 0, 0)
    end_time = datetime(2021, 7, 1, 23, 59)
    print(f"BACKTEST from {start_time} to {end_time}")
    current_date = start_time.strftime("%d/%m/%Y")
    for manager in backtest(start_time, end_time):
        btc_value = manager.collate_coins("BTC")
        bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
        btc_fees_value = manager.collate_fees("BTC")
        bridge_fees_value = manager.collate_fees(manager.config.BRIDGE.symbol)
        trades = manager.trades
        history.append((btc_value, bridge_value, trades, btc_fees_value,
                        bridge_fees_value))
        btc_diff = round((btc_value - history[0][0]) / history[0][0] * 100, 3)
        bridge_diff = round(
            (bridge_value - history[0][1]) / history[0][1] * 100, 3)
        if manager.datetime.strftime("%d/%m/%Y") != current_date:
            current_date = manager.datetime.strftime("%d/%m/%Y")
            print("------")
            print("TIME:", manager.datetime)
            print("TRADES:", trades)
            #print("PAID FEES:", manager.paid_fees)
            #print("BTC FEES VALUE:", btc_fees_value)
            print(f"{manager.config.BRIDGE.symbol} FEES VALUE:",
                  bridge_fees_value)
            #print("BALANCES:", manager.balances)
示例#6
0
from datetime import datetime

from binance_trade_bot import backtest

if __name__ == "__main__":
    history = []
    for manager in backtest(datetime(2020, 4, 1), datetime(2020, 5, 1)):  # datetime.now()):
        btc_value = manager.collate_coins("BTC")
        bridge_value = manager.collate_coins(manager.config.BRIDGE.symbol)
        history.append((btc_value, bridge_value))
        btc_diff = round((btc_value - history[0][0]) / history[0][0] * 20, 3)
        bridge_diff = round((bridge_value - history[0][1]) / history[0][1] * 20, 3)
        print("------")
        print("TIME:", manager.datetime)
        print("BALANCES:", manager.balances)
        print("BTC VALUE:", btc_value, f"({btc_diff}%)")
        print(f"{manager.config.BRIDGE.symbol} VALUE:", bridge_value, f"({bridge_diff}%)")
        print("------")