Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: publish feed price automatic(From BitSuperLab)  (Read 6208 times)

Offline alt

publish feed price automatic(From BitSuperLab)
« on: August 28, 2014, 02:18:26 AM »

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 »
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline heyD

  • Hero Member
  • *****
  • Posts: 717
  • BitShares everything
    • View Profile
Re: publish feed price automatic(From BitSuperLab)
« Reply #1 on: August 28, 2014, 02:36:36 AM »
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 xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11904
    • View Profile
    • BitShares.Europe
  • BTS: xeroc
  • GitHub: xeroc
Re: publish feed price automatic(From BitSuperLab)
« Reply #2 on: August 28, 2014, 07:50:06 AM »
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 »
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu

Offline alt

Re: publish feed price automatic(From BitSuperLab)
« Reply #3 on: August 28, 2014, 12:06:21 PM »
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
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline puppies

Re: publish feed price automatic(From BitSuperLab)
« Reply #4 on: August 28, 2014, 08:06:56 PM »
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 xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11904
    • View Profile
    • BitShares.Europe
  • BTS: xeroc
  • GitHub: xeroc
Re: publish feed price automatic(From BitSuperLab)
« Reply #5 on: August 28, 2014, 08:13:06 PM »
Yhea. .. switch the port over to

"httpd_endpoint": "127.0.0.1:9988",

and leave the RPC with something welse
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu

Offline puppies

Re: publish feed price automatic(From BitSuperLab)
« Reply #6 on: August 28, 2014, 08:33:34 PM »
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 alt

Re: publish feed price automatic(From BitSuperLab)
« Reply #7 on: August 28, 2014, 11:39:59 PM »
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?
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline Riverhead

Re: publish feed price automatic(From BitSuperLab)
« Reply #8 on: August 28, 2014, 11:42:09 PM »



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?
BTC/MUSE Bridge! Buy REAL MUSE!  https://metaexchange.info/markets/MUSE/BTC

Offline alt

Re: publish feed price automatic(From BitSuperLab)
« Reply #9 on: August 29, 2014, 12:03:00 AM »
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]
[email protected]:~/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 »
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline puppies

Re: publish feed price automatic(From BitSuperLab)
« Reply #10 on: August 29, 2014, 12:06:11 AM »
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

Re: publish feed price automatic(From BitSuperLab)
« Reply #11 on: August 29, 2014, 01:02:17 AM »
sorry for the confuse, I have update the file readme.md
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline Riverhead

Re: publish feed price automatic(From BitSuperLab)
« Reply #12 on: August 29, 2014, 10:36:15 AM »
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.
BTC/MUSE Bridge! Buy REAL MUSE!  https://metaexchange.info/markets/MUSE/BTC

Offline Riverhead

Re: publish feed price automatic(From BitSuperLab)
« Reply #13 on: August 29, 2014, 10:43:31 AM »
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

BTC/MUSE Bridge! Buy REAL MUSE!  https://metaexchange.info/markets/MUSE/BTC

Offline alt

Re: publish feed price automatic(From BitSuperLab)
« Reply #14 on: August 31, 2014, 05:58:03 AM »
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
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

 

Google+