def test_delete_order(self):
     ok = OkexFutureRest("eth_usd_this_week")
     # 尽可能不成交的价格
     p = ok.get_depth()['asks'][-1]['price']
     res = ok.short(amount=1, price=p, lever_rate=15)
     print(res)
     id = res["order_id"]
     res = ok.delete_order(order_id=id)
     print(res)
Exemple #2
0
 def __init__(self, coin):
     super(OkexWalletAndMarket, self).__init__()
     self.coin = coin
     self.mkt_btc_usd_this_week = OkexFutureRest("btc_usd_this_week")
     self.mkt_btc_usd_next_week = OkexFutureRest("btc_usd_next_week")
     self.mkt_btc_usd_quarter = OkexFutureRest("btc_usd_quarter")
     self.data = {}
     self.client = MongoClient('localhost', 27017)
     self.db = self.client.account
 def test_close_short(self):
     ok = OkexFutureRest("eth_usd_this_week")
     res = OkexFutureRest("eth_usd_this_week").close_short(amount=1)
     print(res)
 def test_short(self):
     ok = OkexFutureRest("eth_usd_this_week")
     ticker = ok.get_ticker()
     price = ticker['ask']['price']
     res = OkexFutureRest("eth_usd_this_week").short(amount=1, price=price)
     print(res)
 def test_long(self):
     ok = OkexFutureRest("eth_usd_this_week")
     ticker = ok.get_ticker()
     price = ticker['bid']['price']
     res = OkexFutureRest("eth_usd_this_week").long(amount=1, price=price)
     print(res)
 def test_get_depth(self):
     while True:
         ticker = OkexFutureRest("btc_usd_this_week").get_depth()
         print(ticker['asks'])
         time.sleep(0.5)
 def test_get_ticker(self):
     ticker = OkexFutureRest("eth_usd_this_week").get_ticker()
     print(ticker)
     return ticker
 def test_get_account(self):
     ok = OkexFutureRest("eth_usd_this_week")
     print(ok.get_account())