Author Topic: 100 BitUSD to First Person to Publish a working Price Feed Script for Graphene  (Read 10676 times)

0 Members and 1 Guest are viewing this topic.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
I've managed to get the script run, but the result seems a bit wrong.
Code: [Select]
[
    [
        "CNY",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 6670,
                    "asset_id": "1.3.379"
                },
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }
            },
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                },
                "base": {
                    "amount": 6353,
                    "asset_id": "1.3.379"
                }
            }
        }
    ],
...
...
    [
        "USD",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 1044,
                    "asset_id": "1.3.626"
                },
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }
            },
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                },
                "base": {
                    "amount": 995,
                    "asset_id": "1.3.626"
                }
            }
        }
    ]
]
BitShares committee member: abit
BitShares witness: in.abit

Offline bytemaster

So ... assuming the following to be correct:
Code: [Select]
[
    [   
        "USD",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 1044,
                    "asset_id": "1.3.626"
                },
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }
            }, 
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }, 
                "base": {
                    "amount": 995,
                    "asset_id": "1.3.626"
                }   
            }   
        }   
    ], 
    [
        "EUR",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 928,
                    "asset_id": "1.3.424"
                }, 
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }   
            }, 
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }, 
                "base": {
                    "amount": 884,
                    "asset_id": "1.3.424"
                }   
            }   
        }   
    ]   
]
.. I have successfully modified my current price feed script to run for graphene ..
@bytemaster: if 1 BTS is worth $0.007 .. would the following price feed be correct?
Code: [Select]
                "quote": {
                    "amount": 700,
                    "asset_id": "1.3.424"
                }, 
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }   
For now, I used the precision as base amount and the price multiplied by base amount as quote amount ..
Is this how it is supposed to be or am I understanding something wrong?


Code:
https://github.com/xeroc/python-graphenelib/blob/develop/scripts/pricefeeds.py
It requires installation of the python-graphenelib


What you have is almost correct, except it fails to consider the precision difference between BITUSD and BTS.   BTS has 5 digits and BitUSD has 4 so you are off by a factor of 10.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
hmm .. thinking about this approach .. it should be possible to just represent the float as a rational (which is what you had in mind I suppose) and put nominator and denominator into base and quote ..
I will pimp this script this week ..

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
So ... assuming the following to be correct:
Code: [Select]
[
    [   
        "USD",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 1044,
                    "asset_id": "1.3.626"
                },
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }
            }, 
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }, 
                "base": {
                    "amount": 995,
                    "asset_id": "1.3.626"
                }   
            }   
        }   
    ], 
    [
        "EUR",
        {
            "core_exchange_rate": {
                "quote": {
                    "amount": 928,
                    "asset_id": "1.3.424"
                }, 
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }   
            }, 
            "settlement_price": {
                "quote": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }, 
                "base": {
                    "amount": 884,
                    "asset_id": "1.3.424"
                }   
            }   
        }   
    ]   
]
.. I have successfully modified my current price feed script to run for graphene ..
@bytemaster: if 1 BTS is worth $0.007 .. would the following price feed be correct?
Code: [Select]
                "quote": {
                    "amount": 700,
                    "asset_id": "1.3.424"
                }, 
                "base": {
                    "amount": 100000,
                    "asset_id": "1.3.0"
                }   
For now, I used the precision as base amount and the price multiplied by base amount as quote amount ..
Is this how it is supposed to be or am I understanding something wrong?


Code:
https://github.com/xeroc/python-graphenelib/blob/develop/scripts/pricefeeds.py
It requires installation of the python-graphenelib

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
I did successfully published price feed for my bitAsset "ABITUSDA".  :D

Code: [Select]
publish_asset_feed in.abit ABITUSDA {"settlement_price":{"base":{"amount":50000,"asset_id":"1.3.662"},"quote":{"amount":1000000000,"asset_id":"1.3.0"}},"core_exchange_rate":{"base":{"amount":100000,"asset_id":"1.3.0"},"quote":{"amount":10000,"asset_id":"1.3.662"}}} true
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
@abit: thanks for figuring this out .. ill try to finish the script when back home (unless someone else can do more quickly) .. i'd be happy to share the bounty ..

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
I am stuck ..
What's the syntax to hand over a price_feed object?
I am getting:
Code: [Select]
unlocked >>> publish_asset_feed init0 CORE {settlement_price:"0.4"} false
publish_asset_feed init0 CORE {settlement_price:"0.4"} false
4 parse_error_exception: Parse Error
Expected ':' after key "settlement_price"
    {"key":"settlement_price"}
    th_a  json_relaxed.hpp:589 objectFromStream
Error parsing object
    {}
    th_a  json_relaxed.hpp:611 objectFromStream

    {"str":"publish_asset_feed init0 CORE {settlement_price:\"0.4\"} false"}
    th_a  json.cpp:494 variants_from_string

Here is my command which was able to create a transaction, but the transaction got refused by the chain:
Code: [Select]
publish_asset_feed in.abit USD {"settlement_price":{"base":{"amount":50000,"asset_id":"1.3.626"},"quote":{"amount":1000000000,"asset_id":"1.3.0"}},"core_exchange_rate":{"base":{"amount":100000,"asset_id":"1.3.0"},"quote":{"amount":10000,"asset_id":"1.3.626"}}} true

Looks like there is a bug. With current implementation, it's only possible to publish price feed for "committee issued assets" or "private assets", but all bitAssets are "witness issued assets". Submitted an issue here https://github.com/cryptonomex/graphene/issues/328.

p.s.
1. I think the command syntax isn't user-friendly (at all).
2. Can I get some part of the bounty?  8)
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
I am stuck ..
What's the syntax to hand over a price_feed object?
I am getting:
Code: [Select]
unlocked >>> publish_asset_feed init0 CORE {settlement_price:"0.4"} false
publish_asset_feed init0 CORE {settlement_price:"0.4"} false
4 parse_error_exception: Parse Error
Expected ':' after key "settlement_price"
    {"key":"settlement_price"}
    th_a  json_relaxed.hpp:589 objectFromStream
Error parsing object
    {}
    th_a  json_relaxed.hpp:611 objectFromStream

    {"str":"publish_asset_feed init0 CORE {settlement_price:\"0.4\"} false�"}
    th_a  json.cpp:494 variants_from_string

Offline betax

  • Hero Member
  • *****
  • Posts: 808
    • View Profile
Have you developed a split forum personality, xeroc? :)

except that there are now 3!!!! prices per bitasset.

Unfortunatelly, I have no clue why you say there are three prices in price_feed ..  I only see settlement_price, and core_exchange_rate. The other two are 'constants'

lol one forum account isn't enough let's get another one that talks to me :)

LOL that is what I thought!
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc

Offline santaclause102

  • Hero Member
  • *****
  • Posts: 2486
    • View Profile
Have you developed a split forum personality, xeroc? :)

except that there are now 3!!!! prices per bitasset.

Unfortunatelly, I have no clue why you say there are three prices in price_feed ..  I only see settlement_price, and core_exchange_rate. The other two are 'constants'

lol one forum account isn't enough let's get another one that talks to me :)

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
More related info:
https://github.com/cryptonomex/graphene/blob/3eedabbac251b8afa585cb644f4b2b4596f2d37a/libraries/chain/include/graphene/chain/protocol/asset.hpp#L147-L194

Unfortunatelly, I have no clue why you say there are three prices in price_feed ..  I only see settlement_price, and core_exchange_rate. The other two are 'constants'
« Last Edit: September 15, 2015, 08:45:49 am by xeroc »

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
It means bitusd works like it does in 1.0. 


Sent from my iPhone using Tapatalk
That statement will definitelly be misinterprered. Bitusd works differently in bts2 .. just the price feeds for bitusd work the same way .. except that there are now 3!!!! prices per bitasset.

Offline sittingduck

  • Sr. Member
  • ****
  • Posts: 246
    • View Profile
It means bitusd works like it does in 1.0. 


Sent from my iPhone using Tapatalk

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I'm still unclear on who will be publishing feeds for assets?  I was under the impression that this would be something workers would do.  Is this something I will be expected to do as a witness?  Not that I mind or anything, just looking for clarity.
Witnesses publish for the network.
What that means is (iiuc) that witnesses produce feeds for bitassets .. there are also privatized smartcoins which mmay have different producers ..