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

0 Members and 1 Guest are viewing this topic.

Offline alt

  • Hero Member
  • *****
  • Posts: 2806
    • View Profile
  • BitShares: baozi
Re: publish feed price automatic(From BitSuperLab)
« Reply #135 on: December 03, 2014, 04:04:21 am »
Code: [Select]
Warning: unknown error, can't fetch price
2014-12-02 19:23:54,204[ERROR]: 'result'
Traceback (most recent call last):
  File "./bts_feed_auto.py", line 197, in <module>
    fetch_price()
  File "./bts_feed_auto.py", line 100, in fetch_price
    price_depth["bts_usd"] = client.get_depth_in_range("USD","BTS", depth_change)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 43, in get_depth_in_range
    price = self.get_price(quote,base)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 233, in get_price
    order = response.json()["result"]
KeyError: 'result'


latest git pull
looks like your config file about client is not correct, the rpc call can't work

Offline Riverhead

Re: publish feed price automatic(From BitSuperLab)
« Reply #136 on: December 03, 2014, 04:06:58 am »
alt: There is an increasing desire for a price feed for oil. Since most delegates run your feed if you find a way to get that working the market will open up.
do you know where to get the oil price?
I have no idea about hits...

Currently skyscrapperfarms is the only one pushing a feed. I'll ping him and see if he'll share.

Offline chsln

  • Jr. Member
  • **
  • Posts: 43
    • View Profile
Re: publish feed price automatic(From BitSuperLab)
« Reply #137 on: December 03, 2014, 11:17:53 am »
Hi, I have an idea on how to get oil price.

Oil price is taken from futures, and it will change symbol every 15Th day of the month.

for example the symbol for January 2015 on yahoo is CLF15.NYM

for February is CLG15.NYM

the symbol it buit as this CL + letter indicating the month + year + .NYM

the months are:

F: JAN
G: FEB
H: MAR
J: APR
K: MAY
M: JUN
N: JUL
Q: AUG
U: SEP
V: OCT
X: NOV
Z: DEC

to get a consistent oil price we should feed the averange price for the last two futures.
For example the actual price should be calculated as:
(CLF15.NYM + CLG15.NYM) / 2

then the 15Th of December it should change to (CLG15.NYM + CLH15.NYM) / 2

Edit: the averange between the two prices should be weighted based on the day it is calculated
« Last Edit: December 03, 2014, 11:24:29 am by chsln »
Delegate: bitfeeds.chsln

Offline monsterer

Re: publish feed price automatic(From BitSuperLab)
« Reply #138 on: December 03, 2014, 12:05:10 pm »
Why wouldn't you just take CLY0, which is the cash price?
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12897
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: publish feed price automatic(From BitSuperLab)
« Reply #139 on: December 03, 2014, 12:35:23 pm »
Why wouldn't you just take CLY0, which is the cash price?
you know of a page that exposes CLY0 through an api?
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline monsterer

Re: publish feed price automatic(From BitSuperLab)
« Reply #140 on: December 03, 2014, 04:27:58 pm »
Why wouldn't you just take CLY0, which is the cash price?
you know of a page that exposes CLY0 through an api?

Not CLY0, no. I did find this, though:

http://www.nasdaq.com/markets/commodities.aspx

NYMEX WTI Crude Oil, and this page has a real time price. It's dirty work, but you could write a script to parse the HTML and pull out the number - they don't have an API, the data is baked into the source.
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline chsln

  • Jr. Member
  • **
  • Posts: 43
    • View Profile
Re: publish feed price automatic(From BitSuperLab)
« Reply #141 on: December 03, 2014, 05:44:18 pm »
Why wouldn't you just take CLY0, which is the cash price?
you know of a page that exposes CLY0 through an api?

Not CLY0, no. I did find this, though:

http://www.nasdaq.com/markets/commodities.aspx

NYMEX WTI Crude Oil, and this page has a real time price. It's dirty work, but you could write a script to parse the HTML and pull out the number - they don't have an API, the data is baked into the source.

That is the same price as CLF15.NYM so it refers to the last future.

CLY0 is shown on barchart but with 0 volume http://www.barchart.com/quotes/futures/CLY0 so i guess it's calculated somehow.

Just a note: most of the prices you get from yahoo or anywhere else for free are delayed at least 10 minutes. It's not real time data. If it is that important to have real time data we'll have to pay to get it.
« Last Edit: December 03, 2014, 05:48:33 pm by chsln »
Delegate: bitfeeds.chsln

Offline monsterer

Re: publish feed price automatic(From BitSuperLab)
« Reply #142 on: December 03, 2014, 09:31:16 pm »
Just a note: most of the prices you get from yahoo or anywhere else for free are delayed at least 10 minutes. It's not real time data. If it is that important to have real time data we'll have to pay to get it.

How much does this typically cost?
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

iHashFury

  • Guest
Re: publish feed price automatic(From BitSuperLab)
« Reply #143 on: December 06, 2014, 04:28:36 pm »
Hello

I have set-up price feeds on my delegate using the following code to run in a tmux terminal:

Code: [Select]
git clone https://github.com/bitsuperlab/operation_tools.git
sudo apt-get install python3-requests python3-numpy
#edit config.json
tmux
cd ~/operation_tools/btsfeed && ./bts_feed_auto.py ALL

and get the following output.

Code: [Select]
===================20141206T172117=======================
    EXCHANGE           PRICE           DEPTH    SCALE
---------------------------------------------------------
       btc38         0.10550    247440.43475  1.00000
        bter         0.10380     26197.36493  1.00000
     bts_cny         0.10744    204827.47117  1.00000
     bts_usd         0.11093       165.00000  1.00000
       yunbi         0.10450     48393.14000  1.00000
---------------------------------------------------------
     average         0.10608
========================================================
===============================================================================================
   ASSET  RATE(CNY)    CURRENT_FEED   CURRENT_PRICE    MEDIAN_PRICE    LAST_PUBLISH   CHANGE
-----------------------------------------------------------------------------------------------
    *AUD      5.118               0         0.02073         0.02072         0.02074   -0.07%
    *BTC   2304.853       4.559e-05       4.602e-05       4.601e-05       4.613e-05   -0.27%
    *CAD      5.378               0         0.01973         0.01972         0.01973   -0.07%
    *CHF      6.284               0         0.01688         0.01687         0.01689   -0.07%
    *CNY      1.000          0.1054          0.1061           0.106          0.1061   -0.07%
    *EUR      7.556         0.01394         0.01404         0.01403         0.01404   -0.07%
    *GBP      9.582               0         0.01107         0.01107         0.01108   -0.07%
   *GOLD   7335.958       1.436e-05       1.446e-05       1.446e-05       1.447e-05   -0.07%
    *HKD      0.793               0          0.1337          0.1336          0.1337   -0.07%
    *JPY      0.051               0           2.096           2.096           2.097   -0.07%
    *KRW      0.005               0           19.29           19.28           19.29   -0.07%
    *MXN      0.428               0          0.2476          0.2475          0.2477   -0.07%
    *NZD      4.742               0         0.02237         0.02236         0.02238   -0.07%
    *RUB      0.117               0          0.9082          0.9079          0.9086   -0.07%
    *SEK      0.814               0          0.1303          0.1303          0.1304   -0.07%
    *SGD      4.650               0         0.02281         0.02281         0.02282   -0.07%
 *SILVER     99.609               0        0.001065        0.001065        0.001065   -0.07%
    *TRY      2.721               0         0.03899         0.03898         0.03901   -0.07%
    *USD      6.150         0.01712         0.01725         0.01724         0.01725   -0.07%
===============================================================================================

How does the market_weight scale work and what scale should I use?
Is that my delegate ready to publish price feeds?

Thanks

Xeldal

  • Guest
Re: publish feed price automatic(From BitSuperLab)
« Reply #144 on: December 06, 2014, 04:54:19 pm »
Still getting errors..

Code: [Select]
git clone https://github.com/Bitsuperlab/operation_tools.git
cd operation_tools/btsfeed
cp config-sample.json config.json
./bts_feed_auto.py ALL


Code: [Select]
cat log-bts.txt
2014-12-05 10:33:49,277[ERROR]: Warning: unknown error, can't fetch price
2014-12-05 10:33:49,278[ERROR]: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "./bts_feed_auto.py", line 197, in <module>
    fetch_price()
  File "./bts_feed_auto.py", line 100, in fetch_price
    price_depth["bts_usd"] = client.get_depth_in_range("USD","BTS", depth_change)
  File "/home/bitcoiners/local/operation_tools/btsfeed/bts.py", line 43, in get_depth_in_range
    price = self.get_price(quote,base)
  File "/home/bitcoiners/local/operation_tools/btsfeed/bts.py", line 233, in get_price
    order = response.json()["result"]
  File "/usr/lib/python3/dist-packages/requests/models.py", line 756, in json
    return json.loads(self.content.decode(encoding), **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 501, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 393, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Not sure if this is causing your errors but I noticed anywhere that I use a value less than 1 ( like 0.75)  the decimal must be preceded by a zero or I get errors and feeds script will not run. 

.75 does not work
0.75 works fine


Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
Re: publish feed price automatic(From BitSuperLab)
« Reply #145 on: December 09, 2014, 03:53:26 am »
Code: [Select]
Warning: unknown error, can't fetch price
2014-12-02 19:23:54,204[ERROR]: 'result'
Traceback (most recent call last):
  File "./bts_feed_auto.py", line 197, in <module>
    fetch_price()
  File "./bts_feed_auto.py", line 100, in fetch_price
    price_depth["bts_usd"] = client.get_depth_in_range("USD","BTS", depth_change)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 43, in get_depth_in_range
    price = self.get_price(quote,base)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 233, in get_price
    order = response.json()["result"]
KeyError: 'result'


latest git pull
looks like your config file about client is not correct, the rpc call can't work

I have the same error. My delegate is not 101. I checked config.json many times but found no errors yet.

ADD: 0.4.25-RC1
« Last Edit: December 09, 2014, 03:55:41 am by clayop »
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline alt

  • Hero Member
  • *****
  • Posts: 2806
    • View Profile
  • BitShares: baozi
Re: publish feed price automatic(From BitSuperLab)
« Reply #146 on: December 09, 2014, 03:15:05 pm »
update for version 0.4.25

But I have no idea about this problem, the rpc call is failed.
Code: [Select]
Warning: unknown error, can't fetch price
2014-12-02 19:23:54,204[ERROR]: 'result'
Traceback (most recent call last):
  File "./bts_feed_auto.py", line 197, in <module>
    fetch_price()
  File "./bts_feed_auto.py", line 100, in fetch_price
    price_depth["bts_usd"] = client.get_depth_in_range("USD","BTS", depth_change)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 43, in get_depth_in_range
    price = self.get_price(quote,base)
  File "/home/bitcoiners/dev/projects/operation_tools/btsfeed/bts.py", line 233, in get_price
    order = response.json()["result"]
KeyError: 'result'

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
Re: publish feed price automatic(From BitSuperLab)
« Reply #147 on: December 09, 2014, 04:21:25 pm »
update for version 0.4.25

I still have some errors, maybe because I am not 101 delegate. But 0.4.25 support non-delegate to publish feeds.

Code: [Select]
2014-12-09 11:10:52,051[INFO]: btc38: price is 0.09400, depth is 422369.960, scale is 0.900
2014-12-09 11:10:52,052[INFO]: bter: price is 0.09590, depth is 944.661, scale is 1.000
2014-12-09 11:10:52,052[INFO]: bts_cny: price is 0.09542, depth is 155000.000, scale is 1.000
2014-12-09 11:10:52,053[INFO]: bts_usd: price is 0.11139, depth is 0.667, scale is 1.000
2014-12-09 11:10:52,053[INFO]: yunbi: price is 0.09490, depth is 27959.390, scale is 1.100
2014-12-09 11:10:52,053[INFO]: average price is 0.09444
2014-12-09 11:10:52,250[ERROR]: delegate-clayop publish feeds error
2014-12-09 11:10:52,250[ERROR]: {'error': {'message': 'Assert Exception (10)\nmy->is_unique_account(account_name): \n\n\n\n', 'detail': '10 assert_exception: Assert Exception\nmy->is_unique_a$

Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline chsln

  • Jr. Member
  • **
  • Posts: 43
    • View Profile
Re: publish feed price automatic(From BitSuperLab)
« Reply #148 on: December 09, 2014, 04:51:52 pm »
Works for my delegate even if it's not in the top 101
Delegate: bitfeeds.chsln

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
Re: publish feed price automatic(From BitSuperLab)
« Reply #149 on: December 09, 2014, 06:44:19 pm »
Works for my delegate even if it's not in the top 101

Do you have clear log?
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop