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: BTS api for python  (Read 1738 times)

Offline alt

BTS api for python
« on: May 05, 2015, 03:24:45 PM »

I have rewrite some python API for wallet
here is the code
https://github.com/pch957/python-bts

1. rewrite api for wallet
2. rewrite api for exchange
3. bts_delegate_task.py, publish feed, and withdraw pay automatic
4. bts_delegate_watch.py, watch missed block, and send mail attention

this is still a test version, be careful
« Last Edit: May 06, 2015, 07:49:45 AM by alt »
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline toast

Re: BTS api for python
« Reply #1 on: May 05, 2015, 07:36:57 PM »
 +5% This should be the one we merge all the different python BTS tools into
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

Offline alt

Re: BTS api for python
« Reply #2 on: May 06, 2015, 07:52:36 AM »
update:
add bts_delegate_watch.py
a tool to watch missed block, and notification with emai
Code: [Select]
...... 2475721 stan.delegate.xeldal
...... 2475722 elmato
missed 2475723 delegate1.john-galt
no contact
...... 2475723 developer.vikram
...... 2475724 mrs.agsexplorer
missed 2475725 kokojie
no contact
...... 2475725 delegate-dev4.btsnow
...... 2475726 dev.sidhujag

...... 2475732 dev.nathanhourt.com
...... 2475733 delegate-dev2.btsnow
missed 2475734 dacx.baozou
no contact
...... 2475734 delegate1.maqifrnswa

...... 2475821 delegate.liondani
missed 2475822 delegate1.john-galt
no contact
...... 2475822 usd.bts500

...... 2475862 spartako1
missed 2475863 init55
no contact
...... 2475863 www.bts-hk

...... 2475889 delegate.btsnow
missed 2475890 kokojie
no contact
...... 2475890 bm.payroll.riverhead

...... 2475916 testz
missed 2475917 delegate1.john-galt
no contact
...... 2475917 delegate.webber

...... 2475973 delegate-alt
missed 2475974 init55
no contact
...... 2475974 kokojie

...... 2476051 delegate.xeldal
missed 2476052 delegate1.john-galt
no contact
...... 2476052 spartako1

..................
...... 2476076 delegated-proof-of-steak
...... 2476077 dev0.theoretical
...... 2476078 ak
missed 2476079 init55
no contact
...... 2476079 delegate.bitsuperlab
...... 2476080 delegate2.xeldal
...... 2476081 delegate.rgcrypto
...... 2476082 elmato
« Last Edit: May 07, 2015, 02:35:06 PM by alt »
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline alt

Re: BTS api for python
« Reply #3 on: May 07, 2015, 02:29:54 PM »
update
add tools bts_get_market_trx.py
Code: [Select]
[email protected] ~/ $ 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
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline alt

Re: BTS api for python
« Reply #4 on: May 07, 2015, 02:36:17 PM »
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
====================================================
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline alt

Re: BTS api for python
« Reply #5 on: June 04, 2015, 12:36:57 PM »
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
====================================================
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline puppies

Re: BTS api for python
« Reply #6 on: June 04, 2015, 07:14:26 PM »
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 liondani

Re: BTS api for python
« Reply #7 on: June 04, 2015, 10:01:15 PM »
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?
  https://bitshares.OPENLEDGER.info/?r=GREECE  | You are in Control | BUY | SELL | SHORT | SWAP | LOAN | TRADE |  

Offline alt

Re: BTS api for python
« Reply #8 on: June 04, 2015, 10:42:44 PM »
do you mean test your SMTP server? you can use command mail like this
Code: [Select]
[email protected]:~$ mail -s "hello" [email protected]
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?
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline puppies

Re: BTS api for python
« Reply #9 on: June 04, 2015, 10:52:38 PM »
do you mean test your SMTP server? you can use command mail like this
Code: [Select]
[email protected]:~$ mail -s "hello" [email protected]
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

Re: BTS api for python
« Reply #10 on: June 04, 2015, 10:53:17 PM »
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]
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline alt

Re: BTS api for python
« Reply #11 on: June 04, 2015, 11:04:52 PM »
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]
[email protected]:~$ mail -s "hello" [email protected]
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 »
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

Offline clayop

Re: BTS api for python
« Reply #12 on: June 04, 2015, 11:06:00 PM »
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 puppies

Re: BTS api for python
« Reply #13 on: June 04, 2015, 11:08:13 PM »


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 alt

Re: BTS api for python
« Reply #14 on: June 04, 2015, 11:18:56 PM »
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             }
wallet_account_set_approval  delegate.baozi 1
personal asset:  PAYALT(hourly pay for alt)

 

Google+