示例#1
0
文件: robot1.py 项目: cc5985/robot
import sys
sys.path.append("..")
from packages import aex as AEX
from packages import account as ACCOUNT
from packages import currency_pair as CP
from strategies import triangle_arbitrage as TRI
import time

USER_ID=472702
account=ACCOUNT.Account('426817f2228d6d8f485dff7b8a9aee71','41ebfb59508cd77031a25228758755dc10f566c18b19f13c52e39ca4c69d775f')
aex=AEX.AEX(account,USER_ID)

# get all tradable currency pairs:
currency_pairses=CP.CurrencyPair.find_triangle_arbitragable_currency_pairs('aex',account,USER_ID)

# get all distinctive currency pair:
distinctive_currency_pairs=[]
for currency_pairs in currency_pairses:
    for currency_pair in currency_pairs:
        if not distinctive_currency_pairs.__contains__(currency_pair):
            distinctive_currency_pairs.append(currency_pair)

# get relative prices of all currency pairs:
initial_funds={}
tickers = {}
tickers['cny'] = aex.ticker(CP.CurrencyPair('all', 'cny'), True)
tickers['usdt'] = aex.ticker(CP.CurrencyPair('all', 'usdt'), True)
# reformat tickers
_tickers = {}
for key1 in tickers.keys():
    for key2 in tickers[key1]:
示例#2
0
 def get_all_currency_pairs(cls, market, account=None, user_id=None):
     market = str(market).lower()
     if market == 'digifinex':
         from packages import digifinex as DIGIFINEX
         digifinex = DIGIFINEX.DigiFinex(account)
         tickers = digifinex.ticker()
         # 在digiFinex返回的tickers数据结构里,每个项的vol字段的值指的是base的成交量,而不是reference的成交量,所以首先要变成reference成交量
         currency_pairs = {
             'usdt': [],
             'btc': [],
             'usdt2': [],
             'eth': [],
             'dft': []
         }
         # currency_pairs_in_reference_of_btc=[]
         # currency_pairs_in_reference_of_usdt = []
         # currency_pairs_in_reference_of_usdt2 = []
         # currency_pairs_in_reference_of_eth = []
         # currency_pairs_in_reference_of_dft = []
         for item in dict(tickers).keys():
             base = str(item).split('_')[1]
             reference = str(item).split('_')[0]
             currency_pair = CurrencyPair(base, reference)
             vol = tickers[item]['vol'] * tickers[item]['last']
             currency_pairs[reference].append({
                 'currency_pair': currency_pair,
                 'vol': vol,
                 'reference': reference
             })
         #     sorted(x, key=lambda x : x['name'], reverse=True)
         for item in currency_pairs.keys():
             currency_pairs[item] = sorted(currency_pairs[item],
                                           key=lambda x: x['vol'],
                                           reverse=True)
     if market == 'aex':
         from packages import aex as AEX
         aex = AEX.AEX(account, user_id)
         tickers = {}
         tickers['cny'] = aex.ticker(CurrencyPair('all', 'cny'), True)
         tickers['usdt'] = aex.ticker(CurrencyPair('all', 'usdt'), True)
         # 在digiFinex返回的tickers数据结构里,每个项的vol字段的值指的是base的成交量,而不是reference的成交量,所以首先要变成reference成交量
         _tickers = {}
         for key1 in tickers.keys():
             for key2 in tickers[key1]:
                 if key1 + '_' + key2 == 'usdt_tusd' or key1 + '_' + key2 == 'usdt_pax':
                     continue
                 _tickers[key1 + '_' + key2] = tickers[key1][key2]['ticker']
         tickers = _tickers
         currency_pairs = {'usdt': [], 'cny': []}
         for item in dict(tickers).keys():
             base = str(item).split('_')[1]
             reference = str(item).split('_')[0]
             currency_pair = CurrencyPair(base, reference)
             vol = tickers[item]['vol'] * tickers[item]['last']
             currency_pairs[reference].append({
                 'currency_pair': currency_pair,
                 'vol': vol,
                 'reference': reference
             })
         #     sorted(x, key=lambda x : x['name'], reverse=True)
         for item in currency_pairs.keys():
             currency_pairs[item] = sorted(currency_pairs[item],
                                           key=lambda x: x['vol'],
                                           reverse=True)
     return currency_pairs
示例#3
0
import packages.color as CL
from packages import account as AC, coin as CN, currency_pair as CP, currency_pair
from OKEx import okex
import time
import threading
from packages import aex as AEX
# CONSTANTS,所有的外部参数、数值常量、字符串全都在这里定义----------------------------------------
FEE={
    'buy':0,
    'sell':0
}
FEE0 = 0
FEE1 = 0
market = "AEX"
account = AC.Account('426817f2228d6d8f485dff7b8a9aee71','41ebfb59508cd77031a25228758755dc10f566c18b19f13c52e39ca4c69d775f')
aex=AEX.AEX(account,472702)
# okex1 = okex.OKEx(account)
currency_pair_of_bch_usdt = currency_pair.CurrencyPair('bch', 'usdt').get_currency_pair()
currency_pair = 'bch_btc'
color = CL.Colored()

coins = []
coin0 = CN.Coin('btc', 1, 0.01)
coin1 = CN.Coin('cny', 1, 900)
coin2 = CN.Coin('usdt', 1, 128)
coins.append(coin0)
coins.append(coin1)
coins.append(coin2)
btc = coin0
cny = coin1
usdt = coin2