result = api.xcoinApiCall("/info/balance", rgParams); #print(result) bith_balance[c] = result['data']['available_'+c.lower()] #print("{} :\t {}".format(c, result['data']['available_'+c.lower()])) bith_balance['KRW'] = result['data']['available_krw'] for c in bith_balance: if float(bith_balance[c]) > 0: print(c, bith_balance[c]) print("==== Coinone Balance ==== ") from secret import ACCESS_TOKEN, SECRET_KEY from coinone.account import Account from pprint import pprint my = Account(ACCESS_TOKEN, SECRET_KEY) mybal = my.balance() coinone_balance = {} coinone_balance['BTC'] = mybal['btc']['balance'] coinone_balance['ETC']= mybal['etc']['balance'] coinone_balance['ETH']= mybal['eth']['balance'] coinone_balance['KRW']= mybal['krw']['balance'] for c in coinone_balance: if float(coinone_balance[c]) > 0: print(c, coinone_balance[c]) print("==== Polo Balance ==== ") import poloniex polo = poloniex.Poloniex(p_api_key, p_api_secret) polo_balance = polo.returnBalances()
from secret import ACCESS_TOKEN, SECRET_KEY from coinone.account import Account from pprint import pprint if __name__ == "__main__": my = Account(ACCESS_TOKEN, SECRET_KEY) # query account informations #pprint(my.info()) #pprint(my.balance()) #pprint(my.daily_balance()) #pprint(my.deposit_address()) #pprint(my.virtual_account()) # complete orders #pprint(my.complete_orders()) # query for BTC by default #pprint(my.complete_orders('eth')) # query for ETH #try: # pprint(my.complete_orders('bbb')) # will raise error #except Exception as e: # print(e.args) # make some insane orders, and cancel them # will throw error if you have not enough balance #pprint(my.order_book()) #pprint(my.trades()) pprint(my.ticker()) my.order_info(order_id = '32FF744B-D501-423A-8BA1-05BB6BE7814A') # my.buy(price=500, qty=1.000)
from secret import ACCESS_TOKEN, SECRET_KEY from coinone.account import Account from pprint import pprint if __name__ == "__main__": my = Account(ACCESS_TOKEN, SECRET_KEY) # query account informations pprint(my.info()) pprint(my.balance()) pprint(my.daily_balance()) pprint(my.deposit_address()) pprint(my.virtual_account()) # complete orders pprint(my.complete_orders()) # query for BTC by default pprint(my.complete_orders('eth')) # query for ETH try: pprint(my.complete_orders('bbb')) # will raise error except Exception as e: print(e.args) # make some insane orders, and cancel them # will throw error if you have not enough balance my.buy(price=500, qty=1.000) my.buy(price=1000, qty=0.001) my.sell(price=100000000, qty=0.001) print('made 3 orders') orders = my.orders() pprint(orders) my.cancel(**orders[-1]) # cancel the last one
res = self.account.sell(currency=self.target, qty=round(qty - 0.0001, 4)) self.update_balance(res['orderId']) def buy(self): price = self.balance['krw'] res = self.account.buy(currency=self.target, price=price) self.update_balance(res['orderId']) def update_balance(self, order_id): time.sleep(1) # wait until the deal is established orders = self.account.complete_orders(self.target) res = next(filter(lambda o: o['orderId'] == order_id.upper(), orders)) price, qty, fee = float(res['price']), float(res['qty']), float( res['fee']) if res['type'] == 'bid': self.balance['krw'] -= round(price * qty) self.balance[self.target] += qty - fee else: self.balance['krw'] += round(price * qty - fee) self.balance[self.target] -= qty def report(self): logger.info('Balance: %s' % self.balance) if __name__ == "__main__": account = Account(ACCESS_TOKEN, SECRET_KEY) monkey = Monkey(account=account) monkey.start_working()
from settings import ACCESS_TOKEN, SECRET_KEY from coinone.account import Account from pprint import pprint if __name__ == "__main__": my = Account(ACCESS_TOKEN, SECRET_KEY) # query account informations # pprint(my.info()) # pprint(my.balance()) # pprint(my.daily_balance()) # pprint(my.deposit_address()) # pprint(my.virtual_account()) # complete orders # pprint(my.complete_orders()) # query for BTC by default pprint(my.complete_orders('XRP')) # query for ETH try: pprint(my.complete_orders('bbb')) # will raise error except Exception as e: print(e.args) # make some insane orders, and cancel them # will throw error if you have not enough balance my.buy(price=100, qty=1.000) my.buy(price=110, qty=2.000) my.sell(price=100000000, qty=0.001) print('made 3 orders') orders = my.orders() pprint(orders) my.cancel(**orders[-1]) # cancel the last one
from settings import ACCESS_TOKEN, SECRET_KEY from coinone.account import Account from pprint import pprint if __name__ == "__main__": my = Account(ACCESS_TOKEN, SECRET_KEY) # query account informations pprint(my.info()) pprint(my.balance()) pprint(my.daily_balance()) pprint(my.deposit_address()) pprint(my.virtual_account()) # complete orders pprint(my.complete_orders()) # query for BTC by default pprint(my.complete_orders('XRP')) # query for XRP try: pprint(my.complete_orders('bbb')) # will raise error except Exception as e: print(e.args) # make some insane orders, and cancel them # will throw error if you have not enough balance my.buy(price=100, qty=1.000, currency='XRP') my.buy(price=100, qty=2.000, currency='XRP') my.sell(price=1000, qty=3.000, currency='XRP') print('made 3 orders') orders = my.orders(currency='XRP') pprint(orders)