Exemplo n.º 1
0
'''/*---------------------------------------------------------------------------------------------
 *  Copyright (c) VituTech. All rights reserved.
 *  Licensed under the Apache License 2.0. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'''
# from vitu import ai, api, log 这一行必须导入哦
# 同样也可以import平台支持的第三方python模块,比如pandas、numpy等
from vitu import ai, log
import numpy as np
import os
#配置数据导入地址
os.environ["H5_ROOT_DIR"]="/home/john/Downloads/datah5/bundle" #"D:/datah5_m/bundle"
print(os.path.exists(os.environ["H5_ROOT_DIR"]))  #返回True,则数据导入成功
# 配置单/多账户初始持仓信息
ai.create_account(name='account1', exchange='poloniex', account_type='digital.spot', position_base=[{'asset': 'BTC', 'qty': 10},{'asset': 'USDT', 'qty': 200000}])

# initialize方法:设置策略当中会用到的参数,在handle_data方法中可以随时调用
def initialize(context):
    # 我们在这里配置MA策略使用的均线窗口大小和账户对象信息
    context.symbol = "BTC/USDT.poloniex"
    context.MA_length = 1000
    context.account_1 = context.get_account('account1')

#获取深度数据的买卖1档、买卖2档的价格和挂单量

def get_price_qty(depth):
    asks_1 = depth['asks'][0]
    asks_2 = depth['asks'][1]
    bids_1 = depth['bids'][0]
    bids_2 = depth['bids'][1]
    return asks_1,asks_2,bids_1,bids_2
Exemplo n.º 2
0
from vitu import ai, api, log
import numpy as np
import os
#配置数据导入地址
os.environ[
    "H5_ROOT_DIR"] = "/home/john/Downloads/data/opt/data/vitu/bundle"  #"D:/datah5_m/bundle"
print(os.path.exists(os.environ["H5_ROOT_DIR"]))  #返回True,则数据导入成功
# 配置单/多账户初始持仓信息
ai.create_account(name='binance',
                  exchange='binance',
                  account_type='digital.spot',
                  position_base=[{
                      'asset': 'BTC',
                      'qty': 1
                  }])
ai.create_account(name='poloniex',
                  exchange='poloniex',
                  account_type='digital.spot',
                  position_base=[{
                      'asset': 'BTC',
                      'qty': 1
                  }])

# 可以直接指定universe,或者通过筛选条件选择universe池,这里直接指定binance交易所的BTC/USDT、ETH/USDT
universe = ai.create_universe(['BTC/USDT.binance', 'BTC/USDT.poloniex'])
accounts = {}


# initialize方法:设置策略当中会用到的参数,在handle_data方法中可以随时调用
def initialize(context):
Exemplo n.º 3
0
import math
import time
from vitu import ai, log
import numpy as np
import os
#配置数据导入地址
os.environ["H5_ROOT_DIR"] = "/home/john/Downloads/datah5/bundle"
print(os.path.exists(os.environ["H5_ROOT_DIR"]))  #返回True,则数据导入成功
# 配置单/多账户初始持仓信息
ai.create_account(name='account1',
                  exchange='binance',
                  account_type='digital.spot',
                  position_base=[{
                      'asset': 'USDT',
                      'qty': 50000
                  }])


def initialize(context):
    context.symbol = "BTC/USDT.binance"
    context.grids = []
    context.qty = 0.3
    context.grid_direction = 1  # -1向下开网格btc 1向上开网格usdt
    context.grid_num = 15  # 网格数量
    context.set_sep = 40  # 网格间距
    context.cover_spread = 80  # 网格平仓价差
    context.stop_loss_times = 0  # 止损次数
    context.stop_profit_times = 0  # 止盈次数
    context.account = context.get_account('account1')

Exemplo n.º 4
0
from vitu import ai, api, log
import numpy as np

import os
#配置数据导入地址
os.environ[
    "H5_ROOT_DIR"] = "/home/john/Downloads/datah5/bundle"  #"D:/datah5_m/bundle"
print(os.path.exists(os.environ["H5_ROOT_DIR"]))  #返回True,则数据导入成功
# 配置单/多账户初始持仓信息
ai.create_account(name='account_name_1',
                  exchange='binance',
                  account_type='digital.spot',
                  position_base=[{
                      'asset': 'BTC',
                      'qty': 10
                  }, {
                      'asset': 'USDT',
                      'qty': 200000
                  }])
ai.create_account(name='account_name_2',
                  exchange='binance',
                  account_type='digital.spot',
                  position_base=[{
                      'asset': 'ETH',
                      'qty': 200
                  }, {
                      'asset': 'USDT',
                      'qty': 200000
                  }])

# 可以直接指定universe,或者通过筛选条件选择universe池,这里直接指定binance交易所的BTC/USDT、ETH/USDT