Author Topic: Want to calculate exchange rate of any currency?  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: 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!

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
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

Offline 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

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
I am using following api.

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

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

Code: [Select]
{
  "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"
    }
  ]
}



Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
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

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: 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

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
In wallet, click on the "USD/BTS".
BitShares committee member: abit
BitShares witness: in.abit

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
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