Skynet2-0 / Skynet2.0

GNU General Public License v3.0
2 stars 2 forks source link

api agreements #26

Open i-am-xhy opened 8 years ago

i-am-xhy commented 8 years ago

We need to find a common ground with the decentralized market for a api implementation that both partys can work towards

i-am-xhy commented 8 years ago

proposal for an "api agreement" has been send to the other group, awaiting reaction

i-am-xhy commented 8 years ago

The functions we would like to have

create_buy(btc, mc, timeout) btc - float, amount in entire bitcoins mc - float, amount in entire multichain returns - orderId, the class that refers to a specific order

create_ask(btc, mc, timeout) btc - float, amount in entire bitcoins mc - float, amount in entire multichain returns - orderId, the class that refers to a specific order

get_asks() returns - a list of pair (btc, mc) that represent btc mc asks "currently" present

get_buys() returns - a list of pair (btc, mc) that represent btc mc buys "currently" present

get_multichain_balance() returns - float, the current amount of multichain in ~MB (10^6 byte)

functions from orderbook get_*()

mitchellolsthoorn commented 8 years ago

API agreement:

in community.py:

order_book property for accessing the order book class

create_ask(self, price, quantity, timeout): price - (float) bitcoin price in btc (precision to 1/10000) roughly 3 cents quantity - (float) multichain bytes in MB 10^6 (precision to 1/10000) roughly 100 bytes timeout - (float) time from builtin python time format when the order must expire returns - Order object that includes all the information

create_bid(self, price, quantity, timeout): price - (float) bitcoin price in btc (precision to 1/10000) roughly 3 cents quantity - (float) multichain bytes in MB 10^6 (precision to 1/10000) roughly 100 bytes timeout - (float) time from builtin python time format when the order must expire returns - Order object that includes all the information

get_multichain_balance(self) returns - (Quantity object) the current amount of multichain in ~MB (10^6 byte) and bytes both contained in the object

in orderbook.py:

bid_price(self): Return the price an ask needs to have to make a trade :rtype: Price

ask_price(self): Return the price a bid needs to have to make a trade :rtype: Price

bid_side_depth_profile(self): format: [(price (Price object), depth (Quantity object)), (price, depth), ...] Returns the list of bids in the format provided

ask_side_depth_profile(self): format: [(price (Price object), depth (Quantity object)), (price, depth), ...] Returns the list of asks in the format provided

These functions are implemented in the current version of the code Do you agree with this proposal?

StefanBoodt commented 8 years ago

Altough I personally think this is a good proposal there are some things missing.

First is that although it is easy to access the orderbook the way to do it is not in the API. Currently this is MarketCommunityInstance.order_book but it is not standing in the current API. Which means by only the proposal it is inaccessable, the current use in the code is enough (as in no extra coding needs to be done) but the variable is not in the API, so using it now in our code is a little cheating.

A second thing is that although it was said that orderbook.bid_price and orderbook.ask_price would return a price for which a trade can be made, they actually return a price and we can only create bids and asks with an initial float value. Currently only int and str are supported, but both need a little work for them to be converted to the expected floats. Solutions for this problem are implementing a float function on price (and quantity) or defining in the api what their str or int function actually returns so it can be converted in our code.

mitchellolsthoorn commented 8 years ago

Good point, I will add the access to the api and make it more clear how to use the price

mitchellolsthoorn commented 8 years ago

I added the float to the price object, so you can now get the float value

mitchellolsthoorn commented 8 years ago

@i-am-xhy @StefanBoodt I can also add an option to create an ask or bid with the mil units. Is that something you find usefull?

StefanBoodt commented 8 years ago

@mitchellolsthoorn With the implementation of float in price there is no need to do the from mil as floats can be used.

StefanBoodt commented 8 years ago

@mitchellolsthoorn Your float method does not return a float. Instead it returns a Decimal.

mitchellolsthoorn commented 8 years ago

@StefanBoodt Fixed it