예제 #1
0
class TestOkexTradeClient():
    def setUp(self):
        self.tc = OkexTradeClient(*OKEX_CONF)
        self.tcGet = OkexClient(*OKEX_CONF)

    def test_instantiate_tradeclient(self):
        self.assertIsInstance(self.tc, OkexTradeClient)

    def test_get_active_orders_returns_json(self):
        ao = self.tc.active_orders()
        self.assertIsInstance(ao, list)

    def test_get_active_positions_returns_json(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_get_full_history(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_balances(self):
        print self.tc.balances()

    def test_history(self):
        print 'call test_history'
        print self.tc.history('bch_btc', 0)

    def test_ticker(self):
        print 'call test_ticker'
        print self.tcGet.ticker('bch_btc')

    def test_sell(self):
        print 'call place_order'
        print self.tc.place_order('0.2', '0.1', 'buy', symbol='bch_btc')
예제 #2
0
class TestOkexTradeClient():
    def setUp(self):
        self.tc = OkexTradeClient(*OKEX_CONF)
        self.tcGet = OkexClient(*OKEX_CONF)

    def test_instantiate_tradeclient(self):
        self.assertIsInstance(self.tc, OkexTradeClient)

    def test_get_active_orders_returns_json(self):
        ao = self.tc.active_orders()
        self.assertIsInstance(ao, list)

    def test_get_active_positions_returns_json(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_get_full_history(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_balances(self):
        print self.tc.balances()

    def test_history(self):
        print 'call test_history'
        print self.tc.history('bch_btc', 0)

    def test_ticker(self):
        print 'call test_ticker'
        print self.tcGet.ticker('bch_btc')

    def test_sell(self):
        print 'call place_order'
        print self.tc.place_order('0.2', '0.1', 'buy', symbol='bch_btc')
예제 #3
0
from okex.client import OkexClient, OkexTradeClient

proxies = {
    'http': 'socks5h://127.0.0.1:1080',
    'https': 'socks5h://127.0.0.1:1080'
}

client = OkexClient(None, None, proxies)

symbol = 'ltc_btc'

print client.ticker(symbol)
print client.trades(symbol)
print client.depth(symbol)

authClient = OkexTradeClient('', '', proxies=proxies)
print authClient.balances()

print authClient.history('bcc_btc', 1, 500)
예제 #4
0
import matplotlib.pyplot as plt
import pandas as pd
from pprint import pprint
from okex.client import OkexClient, OkexTradeClient, OKexFuture
import time

client = OkexClient(None, None)

symbol = 'btc_usd'

while True:
    tickers = client.ticker('btc_usdt')
    ticker = tickers['ticker']

    date = tickers['date']
    buy = ticker['buy']
    high = ticker['high']
    last = ticker['last']
    low = ticker['low']
    sell = ticker['sell']
    vol = ticker['vol']

    df = pd.DataFrame(ticker, index=pd.Series(date))
    df.index.name = 'date'

    with open('data/' + symbol + '_ticker_spot.csv', 'a') as f:
        df.to_csv(f, header=False)

    time.sleep(1)
예제 #5
0
import matplotlib.pyplot as plt
import pandas as pd
from pprint import pprint
from okex.client import OkexClient, OkexTradeClient, OKexFuture
import time

client = OkexClient(None, None)

symbol = 'btc_usd'

while True:
    tickers = client.ticker('btc_usdt')
    ticker = tickers['ticker']

    date = tickers['date']
    buy = ticker['buy']
    high = ticker['high']
    last = ticker['last']
    low = ticker['low']
    sell = ticker['sell']
    vol = ticker['vol']

    df = pd.DataFrame(ticker,index=pd.Series(date))
    df.index.name = 'date'

    with open('data/'+symbol+'_ticker_spot.csv','a') as f:
        df.to_csv(f, header=False)

    time.sleep(1)