https://github.com/pch957/btsprice
this is a script to fetch BTS's order book from each exchange,
match all order book, get a real price which can give a maximum match volume
display the price and efficient depth
2015/12/10 11:02:48 [195/8526]
+----------+---------------+---------------+---------------+--------------+--------------+
| asset | current(/BTC) | current(/BTS) | current(BTS/) | median(/BTS) | median(BTS/) |
+----------+---------------+---------------+---------------+--------------+--------------+
| AUD | 575.841 | 0.00522667 | 191.326 | 0.00522667 | 191.326 |
| BTC | 1.000 | 0.00000908 | 110173.498 | 0.00000908 | 110173.498 |
| CAD | 568.891 | 0.00516359 | 193.664 | 0.00516359 | 193.664 |
| CHF | 413.016 | 0.00374878 | 266.754 | 0.00374878 | 266.754 |
| CNY | 2749.500 | 0.02495609 | 40.070 | 0.02495609 | 40.070 |
| EUR | 380.983 | 0.00345802 | 289.182 | 0.00345802 | 289.182 |
| GBP | 276.514 | 0.00250981 | 398.437 | 0.00250981 | 398.437 |
| GOLD | 0.390 | 0.00000354 | 282548.404 | 0.00000354 | 282548.404 |
| HANGSENG | 0.149 | 0.00000135 | 738079.277 | 0.00004590 | 21785.530 |
| HKD | 3251.938 | 0.02951652 | 33.879 | 0.02951652 | 33.879 |
| JPY | 51158.537 | 0.46434522 | 2.154 | 0.46434522 | 2.154 |
| KRW | 524375.000 | 4.75953847 | 0.210 | 4.75953847 | 0.210 |
| MXN | 7158.703 | 0.06497663 | 15.390 | 0.06497663 | 15.390 |
| NASDAQC | 0.084 | 0.00000076 | 1319158.894 | 0.00019909 | 5022.870 |
| NIKKEI | 2.686 | 0.00002438 | 41024.779 | 0.00005249 | 19049.660 |
| NZD | 623.606 | 0.00566022 | 176.672 | 0.00566022 | 176.672 |
| RUB | 29131.944 | 0.26441880 | 3.782 | 0.26441880 | 3.782 |
| SEK | 3531.145 | 0.03205076 | 31.201 | 0.03205076 | 31.201 |
| SGD | 589.020 | 0.00534629 | 187.045 | 0.00534629 | 187.045 |
| SHENZHEN | 1.235 | 0.00001121 | 89215.810 | 0.00044914 | 2226.478 |
| SILVER | 29.617 | 0.00026882 | 3719.898 | 0.00026882 | 3719.898 |
| TRY | 1222.319 | 0.01109450 | 90.135 | 0.01109450 | 90.135 |
| USD | 419.500 | 0.00380763 | 262.631 | 0.00380763 | 262.631 |
+----------+---------------+---------------+---------------+--------------+--------------+
efficent depth: 588,510 BTS
+--------------+------------+------------+------------+------------+
| market | bid price | bid_volume | ask price | ask_volume |
+--------------+------------+------------+------------+------------+
| btc38_btc | 0.00000899 | 3,752 | 0.00000917 | 0 |
| btc38_cny | 0.02470900 | 498,000 | 0.02520817 | 142,849 |
| bter_cny | 0.02470900 | 0 | 0.02520817 | 0 |
| poloniex_btc | 0.00000899 | 66,402 | 0.00000917 | 480,023 |
| yunbi_cny | 0.02470900 | 20,355 | 0.02520817 | 0 |
+--------------+------------+------------+------------+------------+
install:
sudo pip install btsprice
upgrade:
sudo pip install btsprice --upgrade
run:
btsprice
next, I'll release a new version which can used by witness to publish feed price
edit: can used by witness now
https://bitsharestalk.org/index.php/topic,20529.msg265069.html#msg265069
#sharebits "alt" 110 PERCENT
#sharebits "alt" 1 GREATIDEA
#sharebits "alt" 5 FISTBUMP
#sharebits "alt" 1 HIGHFIVE
Please wait while your tip is processing, the bot appears to be dead.
Quote from: alt on December 10, 2015, 03:09:36 AM
next, I'll release a new version which can used by witness to publish feed price
Yes ... please do so!!!
Considering the order books is on my list of things to do .. eventually
can used by witness now
copy as config.json, set "witness" to your witness account, run
btsprice --config config.json
{
"witness": "",
"timer_minute": 2,
"asset_list": [
"BTC", "SILVER", "GOLD", "TRY", "SGD", "HKD", "NZD", "CNY", "TCNY",
"MXN", "CAD", "CHF", "AUD", "GBP", "JPY", "EUR", "USD", "KRW"],
"cli_wallet": {
"host" : "localhost",
"port" : 8092,
"user" : "",
"passwd" : "",
"unlock" : ""
},
"price_limit": {
"common": "only update price feed when the change rate is between 1% ~ 50%",
"change_min": 1,
"change_max": 50,
"common": "spread bid price to price*(1+spread), ask price to price*(1-spread)",
"common": "excute the order book, get the real price",
"spread": 0.01,
"common": "we use the average price in this time",
"filter_minute": 30
},
"market_weight": {
"poloniex_btc": 1,
"yunbi_cny": 1,
"btc38_cny": 1,
"btc38_btc": 1,
"bter_cny": 0
},
"asset_config": {
"default": {
"core_exchange_factor": 1.01,
"maintenance_collateral_ratio": 1750,
"maximum_short_squeeze_ratio": 1100
},
"TCNY": {"maximum_short_squeeze_ratio": 1001}
}
}
support TCNY
please upgrade to version 0.1.2, have added some security improve
pip install btsprice --upgrade
d035141 - add security check: set the price invalid if we fetch less than 2 valid market
342f523 - correct the output log message
04d601c - fixed a mistake: duplicated polo's bid order
83b641f - improve the rule for check publish
d6d2344 - fixed a bug
95de4a3 - add more source for BTC's price
90ac147 - update config.json.sample
ad58985 - check feed's lifetime for each asset
bc08baf - set default parameter for TCNY
b00ac3f - fixed a bug
3e4bbea - support TCNY
a2ff023 - support publish feed for witness
1cfd6be - add a valid check for each market, if the price is offset more than 10%, it's invalid
bc69610 - use average price instead of median price
5303b48 - adjust the output
a332f7d - init repo
important upgrade!
only support python3 now.
1. change to async mode, fetch data parallel
2. use push service as a backup, if can't get data from origin website for 3 minutes, wil use data push from the pusher.btsbots.com
you must set config["puser"]["enable"] to 1 if you want to use push service
pip3 install btsprice --upgrade
2015-12-25 11:04 alt o [master] [origin/master] don't need feedapi if not witness
2015-12-25 10:34 alt o new version
2015-12-25 10:30 alt o use sync & pusher for bts feed price
2015-12-25 10:15 alt o add login_info for pusher
2015-12-25 10:14 alt o copy rate
2015-12-25 10:14 alt o must use deepcopy for orderbook
2015-12-25 09:28 alt M─┐ Merge branch 'master' of github.com:pch957/btsprice
2015-12-25 09:26 alt │ o improve: add sorted for get_median
2015-12-24 23:24 alt o │ update test case
2015-12-24 23:23 alt o │ use async to replace request for bts_price_after_match
2015-12-24 20:55 alt o │ a mistake
2015-12-24 20:41 alt o │ add task_pusher, got exchange data from pusher.btsbots.com
2015-12-24 13:34 alt o │ dependency
2015-12-24 07:54 alt o │ a mistake
2015-12-24 07:53 alt o │ remove log of exchanges
2015-12-23 20:09 alt o │ add class TaskExchanges, fetch all data needed by price feed from
2015-12-23 17:17 alt o │ change to async
2015-12-23 17:16 alt o │ change to async
please upgrade to the new version 0.2.16 to fetch price from btc38 correctly
upgrade to version 0.2.27,
disable btc price from China exchange
add orderbook from btsbots, include: CNY/BTS, USD/BTS, OPEN.BTC/BTS
to enable these market, add these lines to config file:
"market_weight": {
+ "btsbots_cny": 0.5,
+ "btsbots_usd": 0.5,
+ "btsbots_open.btc": 1.0,
"poloniex_btc": 1,
"yunbi_cny": 1,
"btc38_cny": 1,
Thanks
@altwitness.yao has updated to v0.2.27
Nice. delegate-1.lafona also updated to v0.2.27
due to the USDT issue, the BTC price from poloniex.com is unusable
so I have add several new source for BTC price include: btc-e USD/BTC, bitstamp USD/BTC, okcoin.com USD/BTC
please upgrade to the new version