Author Topic: BTS api for python  (Read 10618 times)

0 Members and 1 Guest are viewing this topic.

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
I made it! Thanks :)
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
ah, you need to install python-setuptools,
Code: [Select]
sudo apt-get install python-setuptools
in fact you can run directly  without install
Code: [Select]

python scripts/bts_delegate_task.py

Code: [Select]
git clone https://github.com/pch957/python-bts
cd python-bts
python setup.py build

Got an error

Code: [Select]
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools
« Last Edit: June 05, 2015, 12:40:40 am by alt »

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
Code: [Select]
git clone https://github.com/pch957/python-bts
cd python-bts
python setup.py build

Got an error

Code: [Select]
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
Thanks alt but I failed to install the tool. Can you explain how to install from the scratch? (e.g. required packages, line-by-line commands)
my English is not good, so the document is not clear...
step by step:
1. git clone source code to directory python-bts
2. change dir to python-bts, and run command
Code: [Select]
python setup.py build
sudo python setup.py install
3. configure
configure directory is $HOME/.python-bts, for the first time, you can copy sample config file from sourcecode_direcotry/config
Code: [Select]
mkdir ~/.python-bts
cp config/* ~/.python-bts

1) setup rpc info at config file bts_client.json
2) setup price feed info at delegate_task.jon:
this you must configure
Code: [Select]
config["delegate_task"]["delegate_list"]
these you can adjust for price rule, there is a common for each parameter
Code: [Select]
19             "price_limit": {
 20                 "common": "only update price feed when the change rate is between 0.5% ~ 50%",
 21                 "change_ignore": 0.2,
 22                 "change_min": 0.5,
 23                 "change_max": 50,
 24                 "common": "spread bid price to price*(1+spread), ask price to price*(1-spread)",
 25                 "common": "excute the order book, get the real price",
 26                 "spread": 0.01,
 27                 "common": "we use the median price, how many samples need to use",
 28                 "median_length": 9
 29             },
 30             "market_weight": {
 31                 "common": "weight depenth on (depth * scale)",
 32                 "wallet_usd": 0.001,
 33                 "wallet_cny": 1,
 34                 "yunbi_cny": 1,
 35                 "btc38_cny": 1,
 36                 "btc38_btc": 1,
 37                 "bter_cny": 1
 38             }

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies


to test email , you can modify the script.
Code: [Select]
293     -  delegate_task.excute()                                                                                                                                         
294     + delegate_task.pay_notify("anything", "your bts id to receive payment", 100, 1.0)




Thanks alt.  You rock.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
Thanks alt but I failed to install the tool. Can you explain how to install from the scratch? (e.g. required packages, line-by-line commands)
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
there is not this command.....

to enable email notify, need
Code: [Select]
config["notify"]["enable"] = 1

to enable withdraw pay, need
set run_timer to a non zero value
Code: [Select]
config["delegate_task"]["withdraw_pay"]["run_timer"] = 6
make sure you have config the mail list for the bts account to receive the payment
Code: [Select]
config["delegate_task"]["withdraw_pay"]["mail_list"]

to test email , you can modify the script.
Code: [Select]
293     -  delegate_task.excute()                                                                                                                                         
294     + delegate_task.pay_notify("anything", "your bts id to receive payment", 100, 1.0)


do you mean test your SMTP server? you can use command mail like this
Code: [Select]
alt@li430-37:~$ mail -s "hello" test@gmail.com
here is email body
type Ctrl-D to send
EOT

Hey alt, is there a way to test the email feature without missing a block?

No.  Sorry, I should have been clearer.

SMTP is setup and I can email from the command line.  I was just hoping that there was a way to test the scripts call to SMTP.  I want to make sure that I have configured the .jsons correctly. 

For example, it seemed to me that an auto payout should generate an email, but upon auto payout, I do not receive an email. 

I was hoping there was something along the lines of a  bts_delegate_watch.py --test
« Last Edit: June 04, 2015, 11:08:09 pm by alt »

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
I am sorry, the old source is not maintain now
1) install
you can download new source code from
 https://github.com/pch957/python-bts
install with this command
Code: [Select]
python setup.py build
sudo python setup.py install

or run with command
Code: [Select]
pip install bts

2) configure
copy sample config directory to $HOME/.python-bts
edit $HOME/.python-bts/bts_client.json to setup the RPC info

edit $HOME/.python-bts/delegate_task.json to setup price feed info,
config["delegate_task"]["delegate_list"]

3) run
Code: [Select]
bts_delegate_task.py
[/code[


[quote author=liondani link=topic=16170.msg213674#msg213674 date=1433455275]
[color=teal]Warning: unknown error, can't fetch price
'NIKKEI'[/color]

I use the command like this:
./bts_feed_auto.py USD CNY GOLD AUD BTC CAD CHF EUR GBP HKD JPY KRW MXN NZD RUB SEK SGD SILVER TRY NIKKEI



the same when I try the others  :(

Can you suggest what I make wrong?
[/quote]

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
do you mean test your SMTP server? you can use command mail like this
Code: [Select]
alt@li430-37:~$ mail -s "hello" test@gmail.com
here is email body
type Ctrl-D to send
EOT

Hey alt, is there a way to test the email feature without missing a block?

No.  Sorry, I should have been clearer.

SMTP is setup and I can email from the command line.  I was just hoping that there was a way to test the scripts call to SMTP.  I want to make sure that I have configured the .jsons correctly. 

For example, it seemed to me that an auto payout should generate an email, but upon auto payout, I do not receive an email. 

I was hoping there was something along the lines of a  bts_delegate_watch.py --test
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
do you mean test your SMTP server? you can use command mail like this
Code: [Select]
alt@li430-37:~$ mail -s "hello" test@gmail.com
here is email body
type Ctrl-D to send
EOT

Hey alt, is there a way to test the email feature without missing a block?

Offline liondani

  • Hero Member
  • *****
  • Posts: 3737
  • Inch by inch, play by play
    • View Profile
    • My detailed info
  • BitShares: liondani
  • GitHub: liondani
Warning: unknown error, can't fetch price
'NIKKEI'


I use the command like this:
./bts_feed_auto.py USD CNY GOLD AUD BTC CAD CHF EUR GBP HKD JPY KRW MXN NZD RUB SEK SGD SILVER TRY NIKKEI



the same when I try the others  :(

Can you suggest what I make wrong?

Offline puppies

  • Hero Member
  • *****
  • Posts: 1659
    • View Profile
  • BitShares: puppies
Hey alt, is there a way to test the email feature without missing a block?
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
update to version 0.5.12
Code: [Select]
sudo pip install bts --upgrade

support SHENZHEN NASDAQC feed price.. now
SHANGHAI is not available from yahoo, maybe a bug from yahoo finance

Code: [Select]
================ 20150604T123343 ===================
   ASSET  RATE(CNY)    CURRENT_FEED   LAST_PUBLISH
-----------------------------------------------------
     AUD      4.797        0.008262        0.008372
     BTC   1396.318       2.845e-05       2.875e-05
     CAD      4.979        0.007965        0.008066
     CHF      6.651        0.005963        0.006038
     CNY      1.000         0.03968         0.04014
     EUR      7.022        0.005651        0.005721
     GBP      9.543        0.004158        0.004208
    GOLD   7311.348        5.41e-06       5.488e-06
HANGSENG  22038.757            None       1.822e-06
     HKD      0.800         0.04961         0.05019
     JPY      0.050          0.7937          0.8044
     KRW      0.006           7.086           7.168
     MXN      0.399         0.09938          0.1006
 NASDAQC  31620.325            None       1.269e-06
  NIKKEI   1022.361            None       3.926e-05
     NZD      4.430        0.008951        0.009065
     RUB      0.113           0.352          0.3549
     SEK      0.752         0.05281         0.05345
     SGD      4.609        0.008609        0.008712
SHENZHEN   3023.697            None       1.327e-05
  SILVER    102.094       0.0003887       0.0003932
     TRY      2.311         0.01718         0.01737
     USD      6.201        0.006399        0.006473
====================================================

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
this is output for price feed
Code: [Select]
================ 20150507T143416 ===================
   ASSET  RATE(CNY)    CURRENT_FEED   LAST_PUBLISH
-----------------------------------------------------
     AUD      4.915        0.004099        0.004133
     BTC   1437.590       1.413e-05       1.419e-05
     CAD      5.109        0.003945        0.003978
     CHF      6.766         0.00299        0.003015
     CNY      1.000         0.02023          0.0204
     EUR      6.990        0.002889        0.002914
     GBP      9.427        0.002143        0.002161
    GOLD   7343.968       2.749e-06       2.769e-06
     HKD      0.800         0.02527         0.02549
     JPY      0.052          0.3892          0.3923
     KRW      0.006           3.549           3.579
     MXN      0.404          0.0501         0.05043
     NZD      4.623        0.004366        0.004401
     RUB      0.123          0.1647          0.1659
     SEK      0.750         0.02685         0.02708
     SGD      4.658        0.004339        0.004375
  SILVER    102.254       0.0001977       0.0001994
     TRY      2.311        0.008766        0.008828
     USD      6.203        0.003259        0.003287
====================================================

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
update
add tools bts_get_market_trx.py
Code: [Select]
alt@alt-ThinkPad-T430s ~/ $ bts_get_market_trx.py

2015-05-07T11:39:30 2475089 849f13fc short 100000.0 BTS at price 0.019 CNY/BTS
2015-05-07T11:40:40 2475096 73d6aa98 cancel short 100000.0 BTS at price unlimited CNY/BTS
2015-05-07T12:00:20 2475212 b1bbb624 short 30751.16995 BTS at price 0.003053 USD/BTS
2015-05-07T12:01:20 2475218 af01335a bid 60402.5074105 BTS at price 0.02058 CNY/BTS
2015-05-07T12:01:30 2475219 buy 60402.50741 BTS at price 0.02058 CNY/BTS
2015-05-07T12:13:00 2475286 a1aa763f bid 195165.651184 BTS at price 0.02065 CNY/BTS
2015-05-07T12:13:10 2475287 buy 48593.22867 BTS at price 0.02065 CNY/BTS
2015-05-07T12:13:10 2475287 buy 18155.44511 BTS at price 0.02065 CNY/BTS
2015-05-07T12:13:10 2475287 buy 9738.1485 BTS at price 0.02065 CNY/BTS
2015-05-07T12:13:10 2475287 buy 45791.45008 BTS at price 0.02065 CNY/BTS
2015-05-07T12:13:10 2475287 buy 10654.8338 BTS at price 0.02065 CNY/BTS
2015-05-07T12:14:30 2475295 f4f23512 cancel bid 62232.5616312 BTS at price 0.02065 CNY/BTS
2015-05-07T12:21:40 2475338 d51ff7ab cancel bid 494963.569938 BTS at price 0.0202 CNY/BTS.
2015-05-07T12:24:00 2475351 4de9be3a cancel ask 59.6118 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:26:30 2475366 ee45f4ca cancel ask 59.608 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:29:50 2475386 1e512112 cancel ask 59.6087 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:31:40 2475397 5f26ded3 cancel ask 59.6091 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:36:30 2475425 deebd357 short 19961.49778 BTS at price 0.01984 CNY/BTS
2015-05-07T12:47:40 2475490 0a8ccf9f cancel ask 59.6089 CNY at price 1.301 BDR.AAPL/CNY.......................................
2015-05-07T12:48:30 2475495 8f12c7ff ask 50.0 BTS at price 0.02026 CNY/BTS
2015-05-07T12:48:40 2475496 sell 50.0 BTS at price 0.02026 CNY/BTS
2015-05-07T12:49:30 2475501 e07a6c38 cancel ask 59.6094 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:53:20 2475523 f7865b3c cancel ask 59.6096 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:56:40 2475543 54fa6826 cancel ask 59.6091 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T12:59:00 2475556 5d768f88 cancel ask 59.6093 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T13:03:10 2475580 a13f045c cancel ask 59.6096 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T13:04:30 2475588 69d4157d cancel ask 59.6084 CNY at price 1.301 BDR.AAPL/CNY.......................................
2015-05-07T13:07:50 2475608 89be7be5 cancel ask 59.6084 CNY at price 1.301 BDR.AAPL/CNY.......................................
2015-05-07T13:10:20 2475622 0c03a779 cancel bid 493569.770811 BTS at price 0.02026 CNY/BTS.
2015-05-07T13:12:10 2475633 22f93e84 cancel ask 59.609 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T13:27:20 2475721 582fd95f cancel ask 64900.00001 BTS at price 4.237 NOTE/BTS
2015-05-07T13:28:30 2475726 c5732e98 ask 64260.0 BTS at price 4.202 NOTE/BTS
2015-05-07T13:28:50 2475728 ecbcf083 cancel ask 19540.77022 BTS at price 4.235 NOTE/BTS
2015-05-07T13:29:30 2475732 0c898f87 cancel ask 59.6024 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T13:30:00 2475734 670b1ed1 ask 20238.5 BTS at price 4.2 NOTE/BTS
2015-05-07T13:49:50 2475851 fbd8d6fc cancel ask 59.6007 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T13:57:00 2475892 957391e0 cancel ask 59.6015 CNY at price 1.311 BDR.AAPL/CNY.......................................
2015-05-07T14:07:20 2475953 da5ffb22 cancel ask 59.601 CNY at price 1.302 BDR.AAPL/CNY.......................................
2015-05-07T14:09:50 2475968 0a3f4d28 cancel bid 494548.480618 BTS at price 0.02022 CNY/BTS.
2015-05-07T14:12:40 2475984 d69e3d30 bid 100919.999977 BTS at price 4.31 NOTE/BTS
2015-05-07T14:12:50 2475985 buy 20238.5 BTS at price 4.31 NOTE/BTS
2015-05-07T14:12:50 2475985 buy 64260.0 BTS at price 4.31 NOTE/BTS
2015-05-07T14:12:50 2475985 buy 4503.0 BTS at price 4.31 NOTE/BTS
2015-05-07T14:12:50 2475985 buy 990.0 BTS at price 4.31 NOTE/BTS
2015-05-07T14:12:50 2475985 buy 10928.50003 BTS at price 4.31 NOTE/BTS
2015-05-07T14:15:10 2475999 b33e183f bid 46199.8126821 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 9075.81037 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 140.0 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 10000.0 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 990.0 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 2000.0 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 2000.0 BTS at price 4.329 NOTE/BTS
2015-05-07T14:15:20 2476000 buy 21994.00239 BTS at price 4.329 NOTE/BTS
2015-05-07T14:16:20 2476006 14c91376 bid 1432.90550685 BTS at price 0.02065 CNY/BTS
2015-05-07T14:18:00 2476016 79633186 cancel ask 59.6011 CNY at price 1.298 BDR.AAPL/CNY.......................................
2015-05-07T14:18:10 2476017 11e04d35 bid 999.99999 BTS at price 4.151 NOTE/BTS
2015-05-07T14:18:20 2476018 ba1f39db bid 3341.88986293 BTS at price 0.02065 CNY/BTS
2015-05-07T14:18:20 2476018 d872d674 bid 999.99999174 BTS at price 4.235 NOTE/BTS
2015-05-07T14:19:50 2476027 30b818b0 cancel ask 59.6014 CNY at price 1.307 BDR.AAPL/CNY.......................................
2015-05-07T14:22:50 2476045 c5df1fbf cancel ask 59.6014 CNY at price 1.305 BDR.AAPL/CNY.......................................
2015-05-07T14:27:10 2476070 8b7dd98d cancel ask 59.5945 CNY at price 1.301 BDR.AAPL/CNY.......................................
2015-05-07T14:28:50 2476079 690dd3ec cancel bid 155871.794872 BTS at price 0.0195 CNY/BTS
2015-05-07T14:29:20 2476082 c7faaaa6 ask 4774.79537 BTS at price 0.02065 CNY/BTS
2015-05-07T14:29:30 2476083 buy 4774.79536 BTS at price 0.02065 CNY/BTS