CoinCircle / py-etherdelta

Python client for interacting with the EtherDelta API and Smart Contracts.
MIT License
20 stars 12 forks source link

Documentation? #1

Closed Oshawk closed 6 years ago

Oshawk commented 6 years ago

Hello,

Will any documentation be added, this looks to be a very promising library and I would love to know how to use it (as an ameteur).

Thanks, Joseph.

miguelmota commented 6 years ago

@Oshawk yes I'd like to write documentation when time is available. I apologize for lack of documentation. If you need help doing something in particular I can show you an example

Oshawk commented 6 years ago

@miguelmota OK then, I have a few questions:

Thanks, Joseph.

miguelmota commented 6 years ago

@Oshawk here's some examples

# set up client
client = etherdelta.Client()
symbol = 'BAT'

# get all buy and sell orders 
all_orders = client.get_orderbook(symbol)
print(all_orders.result)

# get list of sell orders
sell_orders = client.get_sell_orderbook(symbol)
print(sell_orders.result)

# get the best sell order
best_sell = sell_orders.result[0] 

# get list of buy orders
buy_orders = client.get_sell_orderbook(symbol)
print(orders.result)

# get the best buy order
buy_orders = buy_orders.result[0] 

To generate an order ID, you need to create an order (create_order) and then post the order to the off-chain orderbook (post_order). Then when you query the orderbook, you'll see your order and the order ID.

Oshawk commented 6 years ago

@miguelmota Thanks, I can't even seem to get a simple program to run:

import etherdelta

client = etherdelta.Client()

token = "UKG"
orders = client.get_buy_orderbook(token)

print(orders)

I just get:

error from callback <function Client.listen_once_and_close.<locals>.on_message at 0x7f085b0f8378>: 'orders'
<Deferred at 0x7f085b0f3c50>

Edit: was not using dev of web3, works now.

Oshawk commented 6 years ago

@miguelmota Hello again. I still don't know how to get a list of trade-able tokens or except errors. Sorry to keep bothering you.

miguelmota commented 6 years ago

@Oshawk use this to get the all the ticker data for all tokens

client = etherdelta.Client()
tickers = client.get_tickers()
print(tickers.result)

This package hasn't been fully tested so I appreciate all the feedback you're providing. If you can post all the bugs you're getting that'd be super helpful