Beispiel #1
0
def main(csv_file_path):
    try:
        input_reader = InputReader(csv_file_path)
        data = input_reader.read_file_content()
        for asset, signal in data.items():
            if int(signal) == 1:  # buy signal
                trader = BinanceTrader()
                trader.buy_order(asset)
                # print(asset)
            elif int(signal) == 0:  # sell signal
                trader = BinanceTrader()
                trader.sell_order(asset)
                print(asset)
        sys.exit(0)
    except ValueError as e:
        logger.rootLogger.exception('Error in main:')
        print(f"The CVS file '{csv_file_path}' is not properly formatted.")
        sys.exit(2)
    except Exception as e:
        print("Error Happened", e)
        logger.rootLogger.exception('Error in main:')
        sys.exit(2)
Beispiel #2
0
import logging
from trader.binance_trader import BinanceTrader
from trader.binance_future_trader import BinanceFutureTrader
from utils import config

format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.INFO,
                    format=format,
                    filename='grid_trader_log.txt')
logger = logging.getLogger('binance')

if __name__ == '__main__':

    config.loads('./config.json')

    if config.platform == 'binance_spot':
        trader = BinanceTrader()
    else:
        trader = BinanceFutureTrader()
    orders = trader.http_client.cancel_open_orders(config.symbol)
    print(f"cancel orders: {orders}")

    while True:
        try:
            trader.grid_trader()
            time.sleep(20)

        except Exception as error:
            print(f"catch error: {error}")
            time.sleep(5)
Beispiel #3
0
    服务器购买地址: https://www.ucloud.cn/site/global.html?invitation_code=C1x2EA81CD79B8C#dongjing
"""

import time
import logging
from trader.binance_trader import BinanceTrader
from utils import config

format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'			#配置日志文件格式
logging.basicConfig(level=logging.INFO, format=format, filename='grid_trader_log.txt')	#配置日志文件格式
logger = logging.getLogger('binance')	#配置发送者

if __name__ == '__main__':


    config.loads('./config.json')		# 装载配置文件到config类
    binance_trader = BinanceTrader()	# 实例化BinanceTrader()
	'''http_client属性=binance_spot类的实例,并调用了cancel_open_order得方法'''
    orders = binance_trader.http_client.cancel_open_orders(config.symbol)	# 撤销某个交易对的所有挂单
    print(f"cancel orders: {orders}")		# 打印取消订单返回得josn

    while True:
        try:
            binance_trader.grid_trader()	# 执行网格交易核心逻辑
            time.sleep(120)					# 等待120秒

        except Exception as error:
            print(f"catch error: {error}")
            time.sleep(60)

Beispiel #4
0
    服务器购买地址: https://www.ucloud.cn/site/global.html?invitation_code=C1x2EA81CD79B8C#dongjing
"""

import time
import logging
from trader.binance_trader import BinanceTrader
from utils import config

format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.INFO,
                    format=format,
                    filename='grid_trader_log.txt')
logger = logging.getLogger('binance')

if __name__ == '__main__':

    config.loads('./config.json')
    binance_trader = BinanceTrader()
    orders = binance_trader.http_client.cancel_open_orders(config.symbol)
    print(f"cancel orders: {orders}")

    while True:
        try:
            binance_trader.grid_trader()
            time.sleep(120)

        except Exception as error:
            print(f"catch error: {error}")
            time.sleep(60)