BitShares Forum

Main => Technical Support => Topic started by: monsterer on October 20, 2015, 07:57:05 pm

Title: [API] How to get best bid/ask?
Post by: monsterer on October 20, 2015, 07:57:05 pm
I'm looking at cli_wallet, all I can find is get_limit_orders, but there is no documentation.

Is that just one side of the book? Are the results ordered? Is there a better way to get the orderbook?
Title: Re: [API] How to get best bid/ask?
Post by: maqifrnswa on October 20, 2015, 08:03:47 pm
I'm looking at cli_wallet, all I can find is get_limit_orders, but there is no documentation.

Is that just one side of the book? Are the results ordered? Is there a better way to get the orderbook?

gets the best of both sides.

Documentation is found in the source for now.
https://github.com/bitshares/bitshares-2/blob/bitshares/libraries/wallet/include/graphene/wallet/wallet.hpp
Title: Re: [API] How to get best bid/ask?
Post by: monsterer on October 20, 2015, 08:21:18 pm
gets the best of both sides.

Documentation is found in the source for now.
https://github.com/bitshares/bitshares-2/blob/bitshares/libraries/wallet/include/graphene/wallet/wallet.hpp

Ok, great, its ordered, so:

get_limit_orders BTS USD 1 will get me the best bid ask?

Or is it:

get_limit_orders USD BTS 1

?
Title: Re: [API] How to get best bid/ask?
Post by: maqifrnswa on October 20, 2015, 08:32:28 pm
gets the best of both sides.

Documentation is found in the source for now.
https://github.com/bitshares/bitshares-2/blob/bitshares/libraries/wallet/include/graphene/wallet/wallet.hpp

Ok, great, its ordered, so:

get_limit_orders BTS USD 1 will get me the best bid ask?

Or is it:

get_limit_orders USD BTS 1

?

both will get you the same data, just the order the data is received is reversed. Best is to try both and see what the data looks like. The concept of bid/ask is a little ambiguous as the only operation is to "sell" on asset for another.
Title: Re: [API] How to get best bid/ask?
Post by: bytemaster on October 20, 2015, 08:43:29 pm
Code: [Select]
get_limit_orders USD BTS 1
[{
    "id": "1.7.1148",
    "expiration": "2020-10-20T17:33:00",
    "seller": "1.2.18208",
    "for_sale": 8033,
    "sell_price": {
      "base": {
        "amount": 18533,
        "asset_id": "1.3.121"
      },
      "quote": {
        "amount": 49112450,
        "asset_id": "1.3.0"
      }
    }
  },{
    "id": "1.7.1139",
    "expiration": "2020-10-20T16:45:29",
    "seller": "1.2.32886",
    "for_sale": 260000000,
    "sell_price": {
      "base": {
        "amount": 260000000,
        "asset_id": "1.3.0"
      },
      "quote": {
        "amount": 100000,
        "asset_id": "1.3.121"
      }
    }
  }
]
unlocked >>> get_limit_orders BTS USD 1
get_limit_orders BTS USD 1
[{
    "id": "1.7.1139",
    "expiration": "2020-10-20T16:45:29",
    "seller": "1.2.32886",
    "for_sale": 260000000,
    "sell_price": {
      "base": {
        "amount": 260000000,
        "asset_id": "1.3.0"
      },
      "quote": {
        "amount": 100000,
        "asset_id": "1.3.121"
      }
    }
  },{
    "id": "1.7.1148",
    "expiration": "2020-10-20T17:33:00",
    "seller": "1.2.18208",
    "for_sale": 8033,
    "sell_price": {
      "base": {
        "amount": 18533,
        "asset_id": "1.3.121"
      },
      "quote": {
        "amount": 49112450,
        "asset_id": "1.3.0"
      }
    }
  }
]
Title: Re: [API] How to get best bid/ask?
Post by: monsterer on October 20, 2015, 08:44:44 pm
Thanks :)
Title: Re: [API] How to get best bid/ask?
Post by: roadscape on October 20, 2015, 08:50:10 pm
Here's a good resource for future reference:
http://docs.bitshares.eu/api/database.html

Also this.. but a bit outdated:
https://bitshares.org/doxygen/
Title: Re: [API] How to get best bid/ask?
Post by: monsterer on October 21, 2015, 08:11:31 am
Ok, for clarity's sake, say I want to get the best bid, priced in USD for market BTS/USD - which order is it (1/2), and which sell price is it (base/quote)?
Title: Re: [API] How to get best bid/ask?
Post by: monsterer on October 24, 2015, 06:05:08 pm
Still struggling with this - best I can figure is all the values returned by this function are 10 times too big?

Anyone know how to get a price robustly from this data?
Title: [API] How to get best bid/ask?
Post by: sittingduck on October 24, 2015, 07:29:59 pm
Usd precision is 4 digits.  Bts is 5 digits
Title: Re: [API] How to get best bid/ask?
Post by: xeroc on October 24, 2015, 07:33:55 pm
Precision is part of get_asset .. that will make any pai robust .. you can take a look at the last third of the pricefeed script
Title: Re: [API] How to get best bid/ask?
Post by: monsterer on October 24, 2015, 08:46:57 pm
Precision is part of get_asset .. that will make any pai robust .. you can take a look at the last third of the pricefeed script

Thanks, got it - turned out I had my base quote precisions around the wrong way :)