Author Topic: publish feed price automatic(From BitSuperLab)  (Read 40152 times)

0 Members and 1 Guest are viewing this topic.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
try to print the responce after  call requests.post.
Alt, here is my setup. I'm wondering if it's an iptables issue. I'm going to keep poking at it but if anything jumps out let me know.


BitSharesX setup:
Code: [Select]

{
  "rpc": {
    "enable": true,
    "rpc_user": "test",
    "rpc_password": "testy",
    "rpc_endpoint": "127.0.0.1:0",
    "httpd_endpoint": "127.0.0.1:1579",
    "htdocs": "./htdocs"
  }


btsxfeed setup:
Code: [Select]

{
  "bts_rpc": {
    "url": "127.0.0.1:1579",
    "username": "test",
    "password": "testy"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["riverhead-del-server-1"]
}


netstat:
Code: [Select]

 netstat -nlp | grep bitshares
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:40544           0.0.0.0:*               LISTEN      10892/bitshares_cli
tcp        0      0 127.0.0.1:1578          0.0.0.0:*               LISTEN      10892/bitshares_cli
tcp        0      0 127.0.0.1:1579          0.0.0.0:*               LISTEN      10892/bitshares_cli


btsx_feed_auto.py output
Code: [Select]

 ./btsx_feed_auto.py BTC CNY USD
Fetch: rate usd/cny 6.1433
Fetch: rate xau/cny 7895.0625


================= 20140829T063459 ==================
Warning: unknown error
Warning: unknown error
Fetch: CNY [0.1466, 0.14959] ,ave: 0.148095 ,change: 100.0 %
Warnning: Can't connect to rpc server, retry 5 seconds later
Warnning: Can't connect to rpc server, retry 5 seconds later
^CTraceback (most recent call last):
  File "./btsx_feed_auto.py", line 144, in <module>
    fetch_price()
  File "./btsx_feed_auto.py", line 130, in fetch_price
    update_feed(price_average[asset], asset)
  File "./btsx_feed_auto.py", line 105, in update_feed
    time.sleep(5)
KeyboardInterrupt

Offline Riverhead

Alt, here is my setup. I'm wondering if it's an iptables issue. I'm going to keep poking at it but if anything jumps out let me know.


BitSharesX setup:
Code: [Select]

{
  "rpc": {
    "enable": true,
    "rpc_user": "test",
    "rpc_password": "testy",
    "rpc_endpoint": "127.0.0.1:0",
    "httpd_endpoint": "127.0.0.1:1579",
    "htdocs": "./htdocs"
  }


btsxfeed setup:
Code: [Select]

{
  "bts_rpc": {
    "url": "127.0.0.1:1579",
    "username": "test",
    "password": "testy"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["riverhead-del-server-1"]
}


netstat:
Code: [Select]

 netstat -nlp | grep bitshares
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:40544           0.0.0.0:*               LISTEN      10892/bitshares_cli
tcp        0      0 127.0.0.1:1578          0.0.0.0:*               LISTEN      10892/bitshares_cli
tcp        0      0 127.0.0.1:1579          0.0.0.0:*               LISTEN      10892/bitshares_cli


btsx_feed_auto.py output
Code: [Select]

 ./btsx_feed_auto.py BTC CNY USD
Fetch: rate usd/cny 6.1433
Fetch: rate xau/cny 7895.0625


================= 20140829T063459 ==================
Warning: unknown error
Warning: unknown error
Fetch: CNY [0.1466, 0.14959] ,ave: 0.148095 ,change: 100.0 %
Warnning: Can't connect to rpc server, retry 5 seconds later
Warnning: Can't connect to rpc server, retry 5 seconds later
^CTraceback (most recent call last):
  File "./btsx_feed_auto.py", line 144, in <module>
    fetch_price()
  File "./btsx_feed_auto.py", line 130, in fetch_price
    update_feed(price_average[asset], asset)
  File "./btsx_feed_auto.py", line 105, in update_feed
    time.sleep(5)
KeyboardInterrupt


Offline Riverhead

For those delegates who have published the BitCNY price feed, please update your fed price ASAP. We have reached 46 delegates now.

I can see some prices are not so reasonable.

You may try to use alt's program to update the price feed every time when the price moves up or down by 5% (make sure you have enough funds in your wallet).


Updated. I'm still having trouble getting an RPC connection to my delegate but I'm updating manually. Just having the btsx_feed_auto.py running in a terminal is very useful until I get it working.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
sorry for the confuse, I have update the file readme.md

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
Yeah.  I tried that too.  Running with --server should override that anyways as the command line should override the config.json .  Right?  I'm at work now but I'll try it when I get home.  If I get a chance I'll try it on my vps as well.  I've only tried it on my personal computer and I was also running an instance of the qt wallet.  I can't imagine that would affect it though.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
ah, I see
maybe you should config like this
1. enable rpc
2. in fact, we request rpc service from the http server,
so we need to configure the httpd port.....
Code: [Select]
{
  "rpc": {
    "enable": true,
    "rpc_user": "user",
    "rpc_password": "pass",
    "rpc_endpoint": "127.0.0.1:0",
    "httpd_endpoint": "127.0.0.1:9989",
    "htdocs": "./htdocs"
  },
here is the command to check if rpc server is listening  at the right port , you should see a line with port 9989 available
Code: [Select]
alt@localhost:~/workspace/bitsuperlab/blockchain$ netstat -nlp | grep bitshares
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:1777            0.0.0.0:*               LISTEN      30896/bitshares_cli
tcp        0      0 0.0.0.0:1976            0.0.0.0:*               LISTEN      11434/bitshares_cli
tcp        0      0 127.0.0.1:58075         0.0.0.0:*               LISTEN      30896/bitshares_cli
tcp        0      0 127.0.0.1:57885         0.0.0.0:*               LISTEN      11434/bitshares_cli
tcp        0      0 127.0.0.1:9988          0.0.0.0:*               LISTEN      11434/bitshares_cli
tcp        0      0 127.0.0.1:9989          0.0.0.0:*               LISTEN      30896/bitshares_cli
When it comes time for this to publish my feed I get
Code: [Select]
Warnning: Can't connect to rpc server, retry 5 seconds latermy btsxfeed config JSON looks like this
Code: [Select]
{
  "bts_rpc": {
    "url": "http://localhost:9989/rpc",
    "username": "user",
    "password": "pass"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["dele-puppy"]
}
and my bitshares_client config.json looks like this
Code: [Select]
{
  "rpc": {
    "enable": false,
    "rpc_user": "user",
    "rpc_password": "pass",
    "rpc_endpoint": "127.0.0.1:9989",
    "httpd_endpoint": "127.0.0.1:0",
    "htdocs": "./htdocs"
  },

Any idea what I am doing wrong?
« Last Edit: August 29, 2014, 12:55:27 am by alt »

Offline Riverhead




I was messing with this for a bit today on my Delegate server. Couldn't get it to connect. I put in some debug lines so I could tell exactly where it was failing. It was on the response.post(). The rpc log never showed any activity either. More playing tomorrow :).



the port number is depend on parameter --httpport
and the username/password  depend on parameter --rpcuser/--rpcpassword
for example, here is the command line work for the sample configure.json
Code: [Select]
./bitshares_client  --server --httpport 9989 --rpcuser user --rpcpassword pass

When it comes time for this to publish my feed I get
Code: [Select]
Warnning: Can't connect to rpc server, retry 5 seconds latermy btsxfeed config JSON looks like this
Code: [Select]
{
  "bts_rpc": {
    "url": "http://localhost:9989/rpc",
    "username": "user",
    "password": "pass"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["dele-puppy"]
}
and my bitshares_client config.json looks like this
Code: [Select]
{
  "rpc": {
    "enable": false,
    "rpc_user": "user",
    "rpc_password": "pass",
    "rpc_endpoint": "127.0.0.1:9989",
    "httpd_endpoint": "127.0.0.1:0",
    "htdocs": "./htdocs"
  },

Any idea what I am doing wrong?

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
the port number is depend on parameter --httpport
and the username/password  depend on parameter --rpcuser/--rpcpassword
for example, here is the command line work for the sample configure.json
Code: [Select]
./bitshares_client  --server --httpport 9989 --rpcuser user --rpcpassword pass

When it comes time for this to publish my feed I get
Code: [Select]
Warnning: Can't connect to rpc server, retry 5 seconds latermy btsxfeed config JSON looks like this
Code: [Select]
{
  "bts_rpc": {
    "url": "http://localhost:9989/rpc",
    "username": "user",
    "password": "pass"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["dele-puppy"]
}
and my bitshares_client config.json looks like this
Code: [Select]
{
  "rpc": {
    "enable": false,
    "rpc_user": "user",
    "rpc_password": "pass",
    "rpc_endpoint": "127.0.0.1:9989",
    "httpd_endpoint": "127.0.0.1:0",
    "htdocs": "./htdocs"
  },

Any idea what I am doing wrong?

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
Yhea. .. switch the port over to

"httpd_endpoint": "127.0.0.1:9988",

and leave the RPC with something welse

Still the same error, but at least now it isn't locking up my delegate and killing it.
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
Yhea. .. switch the port over to

"httpd_endpoint": "127.0.0.1:9988",

and leave the RPC with something welse

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
When it comes time for this to publish my feed I get
Code: [Select]
Warnning: Can't connect to rpc server, retry 5 seconds latermy btsxfeed config JSON looks like this
Code: [Select]
{
  "bts_rpc": {
    "url": "http://localhost:9989/rpc",
    "username": "user",
    "password": "pass"
  },
  "asset_list_display": ["CNY", "USD", "BTC"],
  "delegate_list": ["dele-puppy"]
}
and my bitshares_client config.json looks like this
Code: [Select]
{
  "rpc": {
    "enable": false,
    "rpc_user": "user",
    "rpc_password": "pass",
    "rpc_endpoint": "127.0.0.1:9989",
    "httpd_endpoint": "127.0.0.1:0",
    "htdocs": "./htdocs"
  },

Any idea what I am doing wrong?
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
2.    if you just want to watch the price, run command without parameter, update every 1 minute

    ./btsx_feed_auto.py
Code: [Select]
~/operation_tools/btsxfeed$ python2 btsx_feed.py BTC USD CNY
Fetch: rate usd/cny 6.1451
Fetch: rate xau/cny 7920.2964
BTC : [7.87e-05, 7.321e-05] ,average: 7.5955e-05
USD : [0.03677726969455338, 0.03666335779726937] ,average: 0.0367203137459
CNY : [0.226, 0.2253] ,average: 0.22565
do you want to update the feed?(y/n):y
Traceback (most recent call last):
  File "btsx_feed.py", line 135, in <module>
    update_feed()
TypeError: update_feed() takes exactly 2 arguments (0 given)


fixed with:
Code: [Select]
134 if confirm():
135  for asset in asset_list_publish:
136    if len(price[asset]) > 0:
137     update_feed(price_average[asset], asset)
thx

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
2.    if you just want to watch the price, run command without parameter, update every 1 minute

    ./btsx_feed_auto.py
Code: [Select]
~/operation_tools/btsxfeed$ python2 btsx_feed.py BTC USD CNY
Fetch: rate usd/cny 6.1451
Fetch: rate xau/cny 7920.2964
BTC : [7.87e-05, 7.321e-05] ,average: 7.5955e-05
USD : [0.03677726969455338, 0.03666335779726937] ,average: 0.0367203137459
CNY : [0.226, 0.2253] ,average: 0.22565
do you want to update the feed?(y/n):y
Traceback (most recent call last):
  File "btsx_feed.py", line 135, in <module>
    update_feed()
TypeError: update_feed() takes exactly 2 arguments (0 given)


fixed with:
Code: [Select]
134 if confirm():
135  for asset in asset_list_publish:
136    if len(price[asset]) > 0:
137     update_feed(price_average[asset], asset)
« Last Edit: August 28, 2014, 10:49:22 am by xeroc »

Offline muse-umum

  • Hero Member
  • *****
  • Posts: 717
  • BitShares everything
    • View Profile
For those delegates who have published the BitCNY price feed, please update your fed price ASAP. We have reached 46 delegates now.

I can see some prices are not so reasonable.

You may try to use alt's program to update the price feed every time when the price moves up or down by 5% (make sure you have enough funds in your wallet). 


Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
https://github.com/Bitsuperlab/operation_tools/tree/master/btsfeed

how to use this script?

1.    cp config.json.sample to config.json

    edit the rpc parameter, delegate-list ...

2.    if you just want to watch the price, run command without parameter, update every 1 minute

    ./btsx_feed_auto.py

3.    if you want to publish feed,run command with the asset lists, like:

    ./btsx_feed_auto.py USD CNY GLD

    this will update price every 1 minute, and publish the feed price automatic if the change is more than 5% and less than 50%(this value can custom with config.json)
    and will publish at least 23.5 hours,because the feed price will expired after 24 hours.
« Last Edit: November 25, 2014, 03:41:53 pm by alt »