Want to calculate exchange rate of any currency?

Started by sharique-knysys, January 26, 2016, 06:34:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xeroc

This is what I do:
https://github.com/xeroc/python-graphenelib/blob/master/grapheneexchange/exchange.py#L170-L182
you will need the assets precisions aswell!
The example above derives the price as quote/base .. you may want to have it the other way round depending on your application!

sharique-knysys

I tried to calculate from base which has amount 43 and quote has amount 104. I divided base amount/quote amount which means 43/104 = 0.4134. When I checked KRW on cryptofresh.com it showed 4.11 KRW/BTS. So what is the mistake in that? Please point it out. Thanks

svk

You can use the core_exchange_rate object which defines a price. Since this is a bitasset you can also fetch the bitasset_data_id object which contains a settlement_price which is more precise.
Worker: dev.bitsharesblocks

sharique-knysys

I am using following api.

https://bitshares.openledger.info/ws/

I can get this response. How can I calculate exchange rate from this reponse

{
  "id": 2,
  "result": [
    {
      "id": "1.3.102",
      "symbol": "KRW",
      "precision": 4,
      "issuer": "1.2.0",
      "options": {
        "max_supply": "1000000000000000",
        "market_fee_percent": 0,
        "max_market_fee": "1000000000000000",
        "issuer_permissions": 511,
        "flags": 128,
        "core_exchange_rate": {
          "base": {
            "amount": 43,
            "asset_id": "1.3.102"
          },
          "quote": {
            "amount": 104,
            "asset_id": "1.3.0"
          }
        },
        "whitelist_authorities": [],
        "blacklist_authorities": [],
        "whitelist_markets": [],
        "blacklist_markets": [],
        "description": "1 South Korean won",
        "extensions": []
      },
      "dynamic_asset_data_id": "2.3.102",
      "bitasset_data_id": "2.4.2"
    }
  ]
}




abit

Quote from: xeroc on January 26, 2016, 08:54:35 AM
What abit wants to say is that in the BTS/OL wallet you can flip any market by clicking the market in the top navigation bar or by searching for y:x instead of x:y market
Thanks for explanation.
But if OP wants to see something different on CryptoFresh, I have no idea..
BitShares committee member: abit
BitShares witness: in.abit

xeroc

What abit wants to say is that in the BTS/OL wallet you can flip any market by clicking the market in the top navigation bar or by searching for y:x instead of x:y market

abit

BitShares committee member: abit
BitShares witness: in.abit

sharique-knysys

Hi I want to convert any currency to BTS. I have checked currencies on cryptofresh.com. For example how can I calculate that how many bts equal to $1. Like it is displayed on cryptofresh.com

Exchange rate   0.00327 USD/BTS