100 BitUSD to First Person to Publish a working Price Feed Script for Graphene

Started by bytemaster, September 10, 2015, 06:54:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

abit

I've managed to get the script run, but the result seems a bit wrong.

[
    [
        "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

bytemaster

Quote from: xeroc on September 21, 2015, 01:59:03 PM
So ... assuming the following to be correct:

[
    [   
        "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?

                "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: [url="http://bytemaster.bitshares.org"]http://bytemaster.bitshares.org[/url]
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.

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 ..

xeroc

So ... assuming the following to be correct:

[
    [   
        "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?

                "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

abit

I did successfully published price feed for my bitAsset "ABITUSDA".  :D


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

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 ..

abit

Quote from: xeroc on September 18, 2015, 09:37:52 AM
I am stuck ..
What's the syntax to hand over a price_feed object?
I am getting:

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:

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

xeroc

I am stuck ..
What's the syntax to hand over a price_feed object?
I am getting:

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

betax

Quote from: delulo on September 15, 2015, 09:53:06 AM
Have you developed a split forum personality, xeroc? :)

Quote from: xeroc on September 13, 2015, 03:58:11 PM
except that there are now 3!!!! prices per bitasset.

Quote from: xeroc on September 15, 2015, 08:27:28 AM
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!
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads


santaclause102

Have you developed a split forum personality, xeroc? :)

Quote from: xeroc on September 13, 2015, 03:58:11 PM
except that there are now 3!!!! prices per bitasset.

Quote from: xeroc on September 15, 2015, 08:27:28 AM
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 :)

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'

xeroc

Quote from: sittingduck on September 13, 2015, 01:39:32 PM
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.

sittingduck

It means bitusd works like it does in 1.0. 


Sent from my iPhone using Tapatalk

xeroc

Quote from: bytemaster on September 11, 2015, 04:14:00 PM
Quote from: puppies on September 11, 2015, 04:42:01 AM
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 ..