Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - FrankBlabu

Pages: [1]
1
Ok, maybe I got a little close to the solution. The asset precision seems to play some role here, like describes in this example: https://dev.bitshares.works/en/master/bts_guide/tutorials/publish-feed.html

So the price for the asset publish feed operation is computed via

Code: [Select]
...
price = price * 10 ** asset["precision"] / 10 ** base["precision"]
...

which would match the factor 10 as the precision field for BTS is 5 and for EUR it's 4. But I cannot find information about how the asset precision is handled in general. Neither in the bitshares-core source code nor in the documentation. Is there a hint to learn more about that particular topic ? What role does the asset precision play here ?

Best regards.

2
Hi,

no, I think we are talking about USD. At least it's a feed operation, not a trade operation. The issue gets weirder if I inspect a random block at some block explorer service, like here: https://bts.ai/block/35847994.

The website reports 19.97674 BTS/USD from the asset publish feed operation in this block, which is about 0.0500582 USD/BTS. Now when I look at the raw block JSON on the very same site, the published values are 43 USD / 8590 BTS, which is 0.00500582 USD/BTS. Again factor 10 between the rate computed from the raw block content and the value the website computes from that.

I'm afraid I'm missing some basic asset feature here.

Best regards.

3
Hi,

I'm trying to understand the internals of BitShares. For that, I had a deeper look into the operations being passed around and I do not properly understand the "asset publish feed" operation.

If I got that right, the operations settlement/core exchange rate prices are representations of "in the real world, I get x pieces of asset A for y pieces of asset B". So for A being 'USD' and B being 'BTS', it should be possible to directly compute the real world BTS exchange rate in USD from that.

Now, after some debugging, I get values like this for, say, the 2019/2/26:

Code: [Select]
...
{"base":{"amount":238,"asset_id":"1.3.121"},"quote":{"amount":41045,"asset_id":"1.3.0"}}
...

So for 238 USD, I will get 41045 BTS which leads to a price of about 0.0052 USD/BTS.
But if I look up historical BTS pricing, the exchange rate for that particular day is about 0.046 USD/BTS, in general about 10 times larger.

So where is my error of thought here ? Is there some factor involved which is asset specific ?

Thank you very much in advance.

4
If your plugin also uses the internal database, like the market plugin, then your plugin state will also be dumped and reloaded automatically.

Then I must have missed something there and will start analyzing the dump mechanism. Thank you very much for the quick and detailed answer !

UPDATE: Got it ! I simply did not list the database object fields to be stored permanently in the FC_REFLECT_DERIVED clause of the database object. So they never got saved permanently. Case closed, thanks again !

BTW: The bitshares core repo is a really nice piece of code, I already learned a lot !



5
I'm trying to develop a plugin extracting some statistical information from the blockchain. I kept the code similar to the market history plugin and it works well - except that the in-memory database is not rebuild when the witness node has been terminated and then started again - neither for the market history nor for my own plugin. Instead, the blockchain state is rewound for some blocks and blocks will start coming in from that point of time on. All in-memory information from the blocks before is lost.

In detail, the 'applied_block' hook is used to connect to the database during plugin initialization:

Code: [Select]
database ().applied_block.connect ([this] (const signed_block& b) { my->on_block_applied (b); });

When a block is applied, I will consider both applied operations and the current block transactions:

Code: [Select]
void extractor_plugin_impl::on_block_applied( const signed_block& b )
{
        graphene::chain::database& db = database ();

        // Applied operations
        for( const optional< operation_history_object >& o_op : db.get_applied_operations () )
          ...

        // Transactions of incoming block
        operation_handler handler (_plugin, b.block_num (), b.timestamp);

        for (const auto& t : b.transactions)
          for (const auto& op: t.operations)
            ...

This is the output when the witness node is started:

Code: [Select]
...
927579ms th_a       object_database.cpp:115       open                 ] Opening object database from /data/blockchain/bitshares/blockchain ...
928582ms th_a       object_database.cpp:124       open                 ] Done opening object database.
928599ms th_a       db_management.cpp:64          reindex              ] reindexing blockchain
928599ms th_a       db_management.cpp:70          reindex              ] Replaying blocks, starting at 350003...
...

* Is this the right way to ensure that, at witness node restart, the already processed blocks are replayed ? Or is some hook missing ?
* Or do I need to care for storing the already gathered information in a local database myself because there is no replay at all ?
* Why does the official market history plugin fail in this case, too ?

Thank you in advance !

6
That's the explanation. Thank you !

7
Hi,

I have difficulties calling 'get_market_history ()' via the Python API (pybitshares). If I call this function via cli_wallet (local witness node), it works fine:

Code: [Select]
get_market_history BTS USD 3600 "2017-01-01T00:00:00" "2017-01-02T00:00:00"
...

If I do the same call via the Python API, it fails:

Code: [Select]
>>> from bitshares.bitshares import BitShares
>>> node = BitShares ('ws://127.0.0.1:8090')
>>> node.rpc.get_market_history ('BTS', 'USD', 3600, '2017-01-01T00:00:00' '2017-01-02T00:00:00', api='history')
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/bitsharesapi/bitsharesnoderpc.py", line 54, in rpcexec
    return self.rpc.rpcexec(self, payload)
  File "/usr/local/lib/python3.6/dist-packages/grapheneapi/graphenewsrpc.py", line 174, in rpcexec
    raise RPCError(ret['error']['message'])
grapheneapi.exceptions.RPCError: Assert Exception: first_dot != second_dot:

What could I do wrong here ?

Thank you in advance !

8
Yes, great and well documented ! This helps me a lot in understanding the technical background. Thank you very much !


9
Hi,

I would like to learn more about the technology bitshares is based on. For that purpose I am using pybitshares to list the raw operations in the blockchain. Now I wonder how the current (settlement) exchange rate is computed using these operations?

From time to time, an asset feed operation arrives. But this seems not to happen frequent enough to get a settlement exchange rate for every major asset daily or even more frequently. So I assume it is computed from the limit order creates and cancels instead. But how?

Is there documentation about this? Or even a link to a source file implementing the basic algorithm?

Thank you in advance!

Pages: [1]