Ejemplo n.º 1
0
from packages import currency_pair as CP
from packages import account as ACCOUNT

account = ACCOUNT.Account('15d12cfa0a69be',
                          'c6d6a4b051b36e373bb47eede7c1675d05d12cfa0')
currency_pairses = CP.CurrencyPair.find_triangle_arbitragable_currency_pairs(
    'digifinex', account)
for currency_pairs in currency_pairses:
    for currency_pair in currency_pairs:
        print(currency_pair.toString() + '\t', end='')
    print()

# currency_pair=CP.CurrencyPair('btc','usdt')
# other=currency_pair.subtract('abc')
# result1=currency_pair.contains('abc')
# result2=currency_pair.contains('btc')
# print(result1,result2)
a = 1
Ejemplo n.º 2
0
import sys

sys.path.append("..")
from packages import itbit as IB
from packages import account as ACCOUNT
from packages import currency_pair as CP

account = ACCOUNT.Account('577e4a03-540f9610-f686d434-qz5c4v5b6n',
                          'dd7b02f5-c286e9d4-f2cc78c3-bfab3')
ib = IB.Itbit(account)

currency_pair = CP.CurrencyPair('btc', 'usd')
depth = ib.depth(currency_pair)
a = 1
Ejemplo n.º 3
0
from packages import huobi as HB
from packages import itbit as IB
from packages import kraken_rest1 as KK
from packages import kucoin as KC
from packages import liquid as LQ
from packages import okex as OK
from packages import poloniex as PL
from packages import zb as ZB

pgmanager = DB.PGManager(database='quantum',
                         user='******',
                         pw='Caichong416',
                         host='localhost',
                         port='5432')

virtual_account = ACCOUNT.Account('', '')
binance = BN.Binance(virtual_account)
bitfinex = BF.Bitfinex(virtual_account)
bitso = BS.Bitso(virtual_account)
bitstamp = BST.Bitstamp(virtual_account)
bittrex = BTT.Bittrex(virtual_account)
coinbase = CB.Coinbase(virtual_account)
digifinex = DF.DigiFinex(virtual_account)
gate = G.Gateio(virtual_account)
huobi = HB.Huobi(virtual_account)
itbit = IB.Itbit(virtual_account)
kraken = KK.KrakenRest(virtual_account)
kucoin = KC.Kucoin(virtual_account)
liquid = LQ.Liquid(virtual_account)
okex = OK.Okex(virtual_account)
poloniex = PL.Poloniex(virtual_account)
Ejemplo n.º 4
0
account: represents account

'''

# coding=utf-8
from packages import account as AC, currency_pair
from OKEx import okex
from apscheduler.schedulers.blocking import BlockingScheduler
import time

# CONSTANTS:
FEE0 = -0.001
FEE1 = 0.002

market = "OKEx"
account = AC.Account("c008")
okex1 = okex.OKEx(account)
currency_pair_of_bch_usdt = currency_pair.CurrencyPair(
    'bch', 'usdt').get_currency_pair()
currency_pair = 'bch_btc'


def determine_table_name():
    localtime = time.localtime()
    table_name = "depth_OKEx_" + str(localtime[1]).rjust(2, "0") + str(
        localtime[2]).rjust(2, "0")
    return table_name


# 初始化apikey,secretkey,url
# print(account.api_key,account.secret_key,account.name)
Ejemplo n.º 5
0
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]:
Ejemplo n.º 6
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-

from net import mysql_API
from packages import account
from OKEx import okex
import time

mysql_manager = mysql_API.MySQLManager("root", "caichong", "okex")
currencies = ["bch", "eth", "itc"]
references = ["btc"]
market = "OKEx"
account = account.Account("test")
okex1 = okex.OKEx(account)
currency_pair = currencies[0] + '_' + references[0]

# fetch trades data from okex.server using trade_history method:
last_tid = 0

while True:
    results = okex1.trades(currency_pair)
    for result in results:
        timestamp = str(result['date'])
        tid = result['tid']
        type = ("1" if str(result['type']) == 'buy' else "0")
        amount = str(result['amount'])
        price = str(result['price'])
        if tid > last_tid:
            sql_string = 'insert into trades_OKEx_bch_btc_01 values(NULL, ' + timestamp + "," + str(
                tid) + "," + type + "," + amount + "," + price + ")"
            mysql_manager.insert_data(sql_string)
Ejemplo n.º 7
0
import sys
sys.path.append("..")
from packages import okex as OKEX
from packages import account as ACCOUNT
from packages import currency_pair as CP

account = ACCOUNT.Account('d956060d-0892-492c-bf31-20181aeaa09b',
                          '46E6B82DC46915C09614F2EF5C0DDAC4')
okex = OKEX.Okex(account)

currency_pair = CP.CurrencyPair('btc', 'usdt')
depth = okex.depth(currency_pair)
a = 1
Ejemplo n.º 8
0
    #     if p.message=="操作成功":
    #         orders.append(p)


def if_price_changed():
    pass


if len(sys.argv) > 2:
    currency_pair = sys.argv[2]
    account_name = sys.argv[1]
else:
    currency_pair = 'btc_usdt'
    account_name = 'c008'

account = account.Account(account_name)
okex1 = okex.OKEx(account)
cp1 = CP.CurrencyPair()
coin = cp1.get_base_currency(currency_pair)
reference = cp1.get_referencial_currency(currency_pair)


def main(arg):

    MUL_CONSTANT = 1
    previous_bid = 0
    previous_ask = 99999

    my_info = okex1.balances()
    ask_order = None
    bid_order = None
Ejemplo n.º 9
0
import sys
sys.path.append("..")
from packages import aex as AEX
from packages import kraken as KRAKEN
from packages import account as ACCOUNT
from packages import currency_pair as CP
from strategies import triangle_arbitrage as TRI
from packages import universal
import time

account = ACCOUNT.Account(
    '26q2SGG+j42h3PlrA2g2IWfynAQ+YsIAKWrQ6ms2es5GTSQjnTXbuguB',
    'LkpL2am9qfRWA6f3ZPAJqytCHrNk9m9XdQlu5bx95PFzvHh1/e+heb2gKgsSrQ3mfQXUiRQksmqvUEsDgKmIFQ=='
)
kraken = KRAKEN.Kraken(account)
currency_pair = CP.CurrencyPair('btc', 'usdt')

# test for Depth.filter-------------------------------------------------------------------------------------
t1 = time.time()
depths = []
for cnt in range(0, 15):
    depth = kraken.depth(currency_pair, 100)
    time.sleep(0.14)
    depths.append(depth)
t2 = time.time()
import copy
depth0 = copy.deepcopy(depths[0])
print(t2 - t1)
depth = universal.Depth.filter(depths)
t3 = time.time()
print(t3 - t2)
Ejemplo n.º 10
0
import sys
sys.path.append('../')
import time
from packages import binance as BINANCE
from packages import account as ACCOUNT
from packages import currency_pair as CURRENCYPAIR

# pgmanager
from packages import db as DB
import CONSTANTS
pgmanager = DB.PGManager(**CONSTANTS.DB_CONNECT_ARGS_LOCAL)

account = ACCOUNT.Account(
    'gBAyXDQx4SWJ1FKI5cG4xaYJVwTNnMWUVcrvHjNVAKjxmt0JrpLpowQ85Kg49Ak9',
    'EZaHgc67HCNeniUGiLbTBHZJyYsq5MyVPuwOugXUSeTz1mKma1wWaPm3yTeAN7En')
binance = BINANCE.Binance(account)
# liquid=LIQUID.Liquid(account)
# kraken=KRAKEN.Kraken(account)
exchange = binance

currency_pair = CURRENCYPAIR.CurrencyPair('btc', 'usdt')


def digest_data(interval=86400, market='Kraken'):
    _name_map = 'XXBT' + 'Z' + currency_pair.reference.upper()
    # table_name = 'trades_' + currency_pair.base + '_' + currency_pair.reference + '_kraken'
    table_name = 'trades_for_binance'
    # select * from trades_for_binance where tid=(select max(tid) from trades_for_binance)
    sql = 'select * from ' + table_name + ' where tid=(select max(tid) from ' + table_name + ') '
    rows = pgmanager.select(sql)
    if len(rows) == 0:
Ejemplo n.º 11
0
# coding=utf-8

# triangle arbitrage:
import copy
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

# CONSTANTS:
FEE0=-0.001
FEE1= 0.002

market="AEX"
account=AC.Account("test")
okex1= okex.OKEx(account)
currency_pair_of_bch_usdt= currency_pair.CurrencyPair('bch', 'usdt').get_currency_pair()
currency_pair='bch_btc'
color=CL.Colored()

# assume we have c0 c1 c2, each of which has a quantity q0 q1 q2
# we should re-buy c0,c1,c2 in different market/pair at possible low price:
# the c0 we can buy at different markets are:
# you can only buy c0 by selling c2 in pairs[2] or selling c1 in pairs[0]:
# so the quantities of c0 you can buy are:
# f(depths[2],buy='c0',q2)---->in pairs[2]
# f(depths[0],buy='c0',q1)---->in pairs[0]
# the quantities of c1 you can buy are::
# f(depths[0],buy='c1',q0)
# f(depths[1],buy='c1',q2)