Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - litepresence

Pages: 1 [2]
16
When I get this error and it attempts a retry, it never actually does connect because the node itself is down or having issues.

Code: [Select]
Retrying in 2 seconds
Retrying in 4 seconds
Retrying in 6 seconds
etc.

How can I "catch" this retry-attempt like an error? 
How can I provide an argument to prevent any retry at all?

currently the only way I have found, is to use a `multiprocess.Process` approach to enforce a timeout that overrides the retry attempt by starting a side process to contain the node connect attempt, then breaking that process if it takes too long.   

I would rather it just break as soon as it says
Code: [Select]
Retrying in 2 seconds
as I've yet to see a retry actually accomplish anything.

Using a timeout approach has limitations; the timeout must be long enough to account for latency fluctuation, while being short enough to not eat up too much script time.

From my perspective, it would be advantageous if the pybitshares module, rather than attempting a retry on a down node, throws an exception that I can handle with try/except.  Upon exception, I can then specify a new node to attempt... rather than waiting for a timeout to expire.



related pybitshares code:

https://github.com/xeroc/python-bitshares/blob/9250544ca8eadf66de31c7f38fc37294c11f9548/bitsharesapi/websocket.py

beginning line 291

Code: [Select]
    def run_forever(self):
        """ This method is used to run the websocket app continuously.
            It will execute callbacks as defined and try to stay
            connected with the provided APIs
        """
        cnt = 0
        while not self.run_event.is_set():
            cnt += 1
            self.url = next(self.urls)
            log.debug("Trying to connect to node %s" % self.url)
            try:
                # websocket.enableTrace(True)
                self.ws = websocket.WebSocketApp(
                    self.url,
                    on_message=self.on_message,
                    on_error=self.on_error,
                    on_close=self.on_close,
                    on_open=self.on_open
                )
                self.ws.run_forever()
            except websocket.WebSocketException as exc:
                if (self.num_retries >= 0 and cnt > self.num_retries):
                    raise NumRetriesReached()

                sleeptime = (cnt - 1) * 2 if cnt < 10 else 10
                if sleeptime:
                    log.warning(
                        "Lost connection to node during wsconnect(): %s (%d/%d) "
                        % (self.url, cnt, self.num_retries) +
                        "Retrying in %d seconds" % sleeptime
                    )
                    time.sleep(sleeptime)

            except KeyboardInterrupt:
                self.ws.keep_running = False
                raise

            except Exception as e:
                log.critical("{}\n\n{}".format(str(e), traceback.format_exc()))


this snippet here is a major source of brittleness:

Code: [Select]
"Lost connection to node during wsconnect(): %s (%d/%d) "
                        % (self.url, cnt, self.num_retries) +
                        "Retrying in %d seconds" % sleeptime

A better behavior than just waiting and retrying on the same failed node is to switch nodes, THEN retry.


or simply raise the exception and let the user handle the failure: switching nodes; perhaps also blacklisting the old, or ringing a bell:

Code: [Select]
except websocket.WebSocketException:
    self.ws.keep_running = False
    raise

where the user could command:

Code: [Select]

attempt = 1
while attempt:

     try:

      # make api call
     attempt = 0

    except websocket.WebSocketException:

      # blacklist this node
      # run routine to find another white-listed node with low latency and non-stale blocktime
      attempt +=1
      if attempt > n:
          # run failsafe routine to generate new node list
      else:
          # switch node to known good node and loop
 


would it be possible to import the websocket.WebsocketException from the bitshares module?

something like

Code: [Select]
from bitshares import websocket.WebsocketException
but that doesn't work

I've also tried

Code: [Select]
from bitshares.websocket import WebsocketException
from bitshares import websocket
from bitshares import WebsocketException
and attempted to import the class function:

Quote
from bitshares import BitSharesWebsocket

but none of them work either, don't mind my ignorance here... just throwing things at the wall to see what sticks

I've also tried importing the websocket module and preempting the exception

Code: [Select]
import websocket

try:
    # connect to api
except websocket.WebsocketException:
    # print ('hello world')

does not catch

17
General Discussion / (Python) latency sorted Bitshares nodes
« on: March 11, 2018, 05:53:11 pm »
Update:  Developing here:
https://github.com/litepresence/extinction-event/blob/master/bitshares-node-latency.py







An "official" list of public nodes is here:

https://github.com/bitshares/bitshares-ui/blob/master/app/api/apiConfig.js

you can fetch it like this:
Code: [Select]
def nodes():  # Public Nodes List

    uri = 'https://raw.githubusercontent.com'
    url = uri+'/bitshares/bitshares-ui/master/app/api/apiConfig.js'
    raw = requests.get(url).text
    clean = ((raw.replace('"',"")).replace("'","")).replace(',','')
    parsed = [ t for t in clean.split() if t.startswith('wss') ]
    validated = [i for i in parsed if (('test' not in i) and ('fake' not in i))]

    return validated


result:
Code: [Select]
print (nodes())

>>>
['wss://bitshares.openledger.info/ws', 'wss://eu.openledger.info/ws', 'wss://bit.btsabc.org/ws', 'wss://bts.ai.la/ws', 'wss://bitshares.apasia.tech/ws', 'wss://japan.bitshares.apasia.tech/ws', 'wss://bitshares.dacplay.org/ws', 'wss://bitshares-api.wancloud.io/ws', 'wss://openledger.hk/ws', 'wss://bitshares.crypto.fans/ws', 'wss://ws.gdex.top', 'wss://dex.rnglab.org', 'wss://dexnode.net/ws', 'wss://kc-us-dex.xeldal.com/ws', 'wss://btsza.co.za:8091/ws', 'wss://api.bts.blckchnd.com', 'wss://eu.nodes.bitshares.ws', 'wss://us.nodes.bitshares.ws', 'wss://sg.nodes.bitshares.ws', 'wss://ws.winex.pro']



usage:
Code: [Select]
from bitshares.market import Market
from bitshares import BitShares

BitCURRENCY = 'OPEN.BTC'
BitASSET = 'BTS'
BitPAIR = BitASSET + ":" + BitCURRENCY
MARKET = Market(BitPAIR, bitshares_instance=BitShares(nodes()))

MARKET.buy()

18
Stakeholder Proposals / [Worker] - Ledger Nano S
« on: March 11, 2018, 02:06:37 pm »
I was wondering if adding BTS support to Ledger Nano would be within the realm of what a worker could be used for.

Thoughts?   I don't have any experience opening a worker... so if this is possible please help.




ledgerwallet >>> cryptocurrencies >>> what's next >>> altcoin support info

https://www.ledgerwallet.com/cryptocurrencies
https://trello.com/b/5nQ1mdzt/ledger-roadmap
https://trello.com/c/4Aa7Ug5a/20-altcoin-support-information

Quote
There are a lot of cryptocurrenies and as Ledger has limited ressources it cannot integrate them all. The conditions to integrate another crypto are one of the following:

massive general support and high market cap (ex: Ethereum)
development sponsored by the coin's community (ex: Litecoin)
direct developer integration using Ledger's SDK
For information, the "altcoin package" costs 149,000 EUR and includes:

  • development of altcoin's Nano S / Blue app
  • altcoin support added to the Ledger Wallet Chrome app
  • altcoin explorer API development for the backend
  • 1,000 Ledger Nano S unit with altcoin's logo laser marking
  • maintenance and support
This pricing is available only for project inheriting from Bitcoin. If the blockchain technology is original (ex: Ripple, IOTA...) then the pricing could be much higher.

If you are part of the project's team and have a deep technical understanding of the coin, we also invite you to fill-in our integration form.

Please also refer to our list of already supported coins and tokens if you are unsure if your favorite coin is supported or not.

Integration only (without custom Nano S units) for Bitcoin clones is available at the separate price of 50,000 EUR.

19
Need a low latency UI for DEX?

[ANN] microDEX
https://bitsharestalk.org/index.php?topic=26201.0


Need a bot?
Runs on local machine?
No subscription fees to pay?
No black box to blindly trust?
 100% open source code?
Backtest and Live session all in one python script?
Trades on Bitshares DEX?
Is aware of outside CEX market prices?
So easy grandma could run it?


[ANN] EXTINCTION EVENT















The Original Code:

https://www.pastebin.com/hzUTtapz

latest version at github here:

https://github.com/litepresence/extinction-event/tree/master/EV

Installation here:

https://github.com/litepresence/extinction-event/blob/master/Installation

Python3 - WTFPLv2*


*Includes Free 30X BTC 5X BTS 1 YEAR BACKTEST


Code: [Select]
EXTINCTION EVENT v0.00000001 alpha release
~=== BEGIN BACKTEST ==================~
API call for chartdata BTC_BTS 1390000000s 1520469392e CANDLE 86400 DAYS 1510
Dataset.....: 420 DAYS
Backtesting.: 365 DAYS
PAIR......: BTC_BTS
BitPAIR...: BTS:OPEN.BTC

CANDLE....: 86400
BEGIN.....: 1488933403 Tue Mar  7 19:36:43 2017

Bitshares
[Tue Mar  7 19:36:43 2017] 1 BUY BEAR DESPAIR 334448.16 BTS at 299 sat value 1.00 BTC
[Tue Mar  7 19:36:43 2017] 2 SELL BEAR RESISTANCE 334448.16 BTS at 307 sat value 1.03 BTC
[Fri Apr  7 20:36:43 2017] 3 BUY BULL SUPPORT 153620.86 BTS at 668 sat value 1.03 BTC
[Sat May  6 20:36:43 2017] 4 SELL BULL OVERBOUGHT 153620.86 BTS at 3013 sat value 4.63 BTC
[Tue May 23 20:36:43 2017] 5 BUY BULL SUPPORT 154826.76 BTS at 2989 sat value 4.63 BTC
[Wed Jun  7 20:36:43 2017] 6 SELL BULL OVERBOUGHT 154826.76 BTS at 8499 sat value 13.16 BTC
[Mon Jun 19 20:36:43 2017] 7 BUY BULL SUPPORT 128380.37 BTS at 10250 sat value 13.16 BTC
[Thu Jul 20 20:36:43 2017] 8 SELL BEAR RESISTANCE 128380.37 BTS at 5825 sat value 7.48 BTC
[Sat Oct  7 20:36:43 2017] 9 BUY BEAR DESPAIR 839235.27 BTS at 891 sat value 7.48 BTC
[Sat Oct 14 20:36:43 2017] 10 SELL BEAR RESISTANCE 839235.27 BTS at 1246 sat value 10.46 BTC
[Sun Nov 19 19:36:43 2017] 11 BUY BULL SUPPORT 919439.38 BTS at 1137 sat value 10.46 BTC
[Mon Dec 18 19:36:43 2017] 12 SELL BULL OVERBOUGHT 919439.38 BTS at 3873 sat value 35.62 BTC
[Wed Jan  3 19:36:43 2018] 13 BUY BULL SUPPORT 825211.57 BTS at 4315 sat value 35.62 BTC
[Sat Jan 27 19:36:43 2018] 14 SELL BEAR RESISTANCE 825211.57 BTS at 4050 sat value 33.42 BTC
===============================================================
START DATE........: Tue Mar  7 19:36:43 2017
END DATE..........: Wed Mar  7 19:36:43 2018
DAYS..............: 365.0
TRADES............: 14
DAYS PER TRADE....: 26.1
START PRICE.......: 0.00000299
END PRICE.........: 0.00001768
START PORTFOLIO...: 1.0 BTC 0.0 BTS
START MAX ASSETS..: 334448.160535 BTS
END MAX ASSETS....: 1890331.92993 BTS
ROI ASSETS........: 5.65X
START MAX CURRENCY: 1.0 BTC
END MAX CURRENCY..: 33.4210685212 BTC
ROI CURRENCY......: 33.42
APY CURRENCY......: 32.42
===============================================================
EXTINCTION EVENT v0.00000001 alpha release
~===END BACKTEST=========================~
#######################################
CURRENCY        = "BTC"
ASSET           = "BTS"
MA1             = 17.00
MA2             = 50.00
SELLOFF         = 2.250
SUPPORT         = 1.000
RESISTANCE      = 1.000
DESPAIR         = 0.525
MIN_CROSS       = 1.000
MAX_CROSS       = 1.000
BULL_STOP       = 1.000
BEAR_STOP       = 1.000
#######################################
# RESOLUTION    : 20
# DAYS          : 365
DPT             = 26.1 # Days Per Trade
# MARKET CAP....: 464.5M
# DOMINANCE.....: 0.1137 - RANK 38
ROI             = 33.42
#######################################


The Tunes:


BTS/BTC 500X https://www.pastecoin.com/6O3QlzeKRNg7
DASH/BTC 25X https://www.pastecoin.com/79j1XgOdQJv6






more alt/btc tunes coming soon








special thanks to:

https://www.youtube.com/watch?v=jJxKXOTNXjc
https://www.youtube.com/watch?v=xV1yUVeA_Fw
https://twitter.com/SEC_News/status/971494501343748097
https://twitter.com/lopp/status/971520121704538112
https://twitter.com/oraclepresence/status/971178302089187328
https://www.reddit.com/r/BinanceExchange/comments/82ou1d/binance_sold_all_my_alt_coins_at_market_rate/
docs.pybitshares.com
coinmarketcap.com/api
cryptocompare.com/api
stackoverflow.com
pastebin.com
pastecoin.com
codeshare.io
chatcrypt.com

20
would be super nice if you could sort by volume standardized to BTS in "Starred Markets" and "Featured Markets";
perhaps even as a replacement of the current "VOLUME" column as it really is pretty meaningless as an effective comparison between markets as they're all in different terms.

also, along w/ "Starred Markets" and "Featured Markets":
would be nice if there was a tab for "Active Markets" which included ANY market with > 0 volume in the past 24 hours

 ;D

21
Code: [Select]
from bitshares.blockchain import Blockchain
import time


def dex(command):

    if command == 'blocktime':

        now = int(time.time())
        chain = Blockchain(mode='head')
        current_block = chain.get_current_block_num()
        blocktime = chain.block_time(current_block)
        blocktimestamp = chain.block_timestamp(current_block)
        drift = now - blocktimestamp
        drifthours = drift/3600
        print ('block           :', current_block)
        print ('blocktime       :', blocktime)
        print ('stamp           :', blocktimestamp)
        print ('ctime(stamp)    :', time.ctime(blocktimestamp))
        print ('now             :', now)
        print ('ctime(now)      :', time.ctime(now))
        print ('drift seconds   :', ('%s' % drift))
        print ('drift hours     :', ('%.2f' % drifthours))
        return current_block, blocktimestamp, drift   

dex('blocktime')


returns

Code: [Select]
block           : 24764676
blocktime       : 2018-02-26 15:03:48
stamp           : 1519675428
ctime(stamp)    : Mon Feb 26 15:03:48 2018
now             : 1519657430
ctime(now)      : Mon Feb 26 10:03:50 2018
drift seconds   : -17998
drift hours     : -5.00



はるか, [26.02.18 09:58]
It's a core bug?

Abit More, [26.02.18 09:58]
Timestamp Without tz

Abit More, [26.02.18 09:58]
But too late to fix

はるか, [26.02.18 09:58]
Timestamp should always be epoch I think

BTS litepresence1, [26.02.18 09:59]
from user perspective I agree

Abit More, [26.02.18 09:59]
When converted to or from String,lack of a z at the end

はるか, [26.02.18 10:00]
ah yes it's missing a Z

はるか, [26.02.18 10:00]
so it needs all clients to manually handle that...

Abit More, [26.02.18 10:00]
Py lib can add it

Abit More, [26.02.18 10:00]
Yes

22
v1 : https://pastebin.com/9zAbqx2A

updated Mar6/2018

v2 https://pastebin.com/pBzi8a4N

 - improved cancel all
 - block number / latency
 - account value in BTS, BTC, USD terms



license: WFTPLv2 http://www.wtfpl.net/about/
Code: [Select]
# python3.4
 
' Wrapper for Common PyBitshares DEX Algo Trading API Calls '
 
# data is in easy to quant float / list of floats / dict of floats format
 
    # buy / sell / cancel
    # outstanding orders
    # account balance for pair
    # complete account balance
    # orderbook
    # last_price
    # account value
    # latency
 
# if no price / amount specified executes market order buy/sell
# if no expiration specified default is 3.2 years
# cancels all outstanding orders in market
 
' BTS: litepresence1 '
 
# http://docs.pybitshares.com
from bitshares.market import Market
from bitshares.account import Account
from bitshares import BitShares
from bitshares.blockchain import Blockchain
import time
 
 
ACCOUNT = Account("")
PASS_PHRASE = ""
 
BitCURRENCY = 'OPEN.BTC'
BitASSET = 'BTS'
BitPAIR = BitASSET + ":" + BitCURRENCY
MARKET = Market(BitPAIR, bitshares_instance=BitShares(nodes()))
CHAIN = Blockchain(bitshares_instance=BitShares(
    nodes()), mode='head')
 
SATOSHI = 0.00000001
ANTISAT = 1 / SATOSHI
 
def nodes():  # Public Nodes List
 
    nodes = [
        'wss://b.mrx.im/ws',
        'wss://bitshares.openledger.info/ws',
        'wss://bitshares.dacplay.org:8089/ws',
        'wss://dele-puppy.com/ws',
        'wss://eu.openledger.info/ws',
        'wss://bit.btsabc.org/ws',
        'wss://eu.openledger.info/ws',
        'wss://dexnode.net/ws',
        'wss://ws.gdex.top',
        'wss://kc-us-dex.xeldal.com/ws',
        'wss://bts.ai.la/ws',
        'wss://btsza.co.za:8091/ws',
        'wss://japan.bitshares.apasia.tech/ws',
        'wss://api.bts.blckchnd.com',
        'wss://bitshares-api.wancloud.io/ws',
        'wss://eu.nodes.bitshares.ws',
        'wss://bitshares.crypto.fans/ws',
        'wss://dex.rnglab.org',
        'wss://bitshares.openledger.info/ws',
        'wss://ws.winex.pro',
        'wss://sg.nodes.bitshares.ws',
        'wss://us.nodes.bitshares.ws',
        'wss://bitshares.apasia.tech/ws',
        'wss://openledger.hk/ws',
        'wss://bitshares.dacplay.org/ws',
    ]
    return nodes
 
def dex(  # Public AND Private API Bitshares
        command, amount=ANTISAT, price=None,
        depth=1, expiration=ANTISAT):
 
    MARKET.bitshares.wallet.unlock(PASS_PHRASE)
    ACCOUNT.refresh()
 
    if command == 'buy':
 
        # buy relentlessly until satisfied or currency exhausted
        print(('Bitshares API', command))
        if price is None:
            price = ANTISAT
        print(('buying', amount, 'at', price))
        attempt = 1
        currency = float(ACCOUNT.balance(BitCURRENCY))
        if amount > 0.998 * currency * price:
            amount = 0.998 * currency * price
        if amount > 0:
            while attempt:
                try:
                    details = (MARKET.buy(price, amount, expiration))
                    print (details)
                    attempt = 0
                except:
                    print(("buy attempt %s failed" % attempt))
                    attempt += 1
                    if attempt > 10:
                        print ('buy aborted')
                        return
                    pass
        else:
            print('no currency to buy')
 
    if command == 'sell':
 
        # sell relentlessly until satisfied or assets exhausted
        expiration = 86400 * 7
        print(('Bitshares API', command))
        if price is None:
            price = SATOSHI
        print(('selling', amount, 'at', price))
        attempt = 1
        assets = float(ACCOUNT.balance(BitASSET))
        if amount > 0.998 * assets:
            amount = 0.998 * assets
        if amount > 0:
            while attempt:
                try:
                    details = (MARKET.sell(price, amount, expiration))
                    print (details)
                    attempt = 0
                except:
                    print(("sell attempt %s failed" % attempt))
                    attempt += 1
                    if attempt > 10:
                        print ('sell aborted')
                        return
                    pass
        else:
            print('no assets to sell')
 
    if command == 'cancel':
 
        # cancel all orders in this MARKET relentlessly until satisfied
        print(('Bitshares API', command)) 
        orders = MARKET.accountopenorders()
        print((len(orders), 'open orders to cancel'))
        if len(orders):
            attempt = 1 
            order_list = []     
            for order in orders:
                order_list.append(order['id'])
            while attempt:
                try:
                    details = MARKET.cancel(order_list)
                    print (details)
                    attempt = 0
                except:
                    print((attempt, 'cancel failed', order_list))
                    attempt += 1
                    if attempt > 10:
                        print ('cancel aborted')
                        return
                    pass   
 
    if command == 'orders':
 
        # dictionary of open orders in traditional format:
        # orderNumber, orderType, market, amount, price
        print(('Bitshares API', command))
        orders = []
        for order in MARKET.accountopenorders():
            orderNumber = order['id']
            asset = order['base']['symbol']
            currency = order['quote']['symbol']
            amount = float(order['base'])
            price = float(order['price'])
            orderType = 'buy'
            if asset == BitASSET:
                orderType = 'sell'
                price = 1 / price
            orders.append({'orderNumber': orderNumber,
                           'orderType': orderType,
                           'market': BitPAIR, 'amount': amount,
                           'price': price})
        for o in orders:
            print (o)
        if len(orders) == 0:
            print ('no open orders')
        return orders
 
    if command == 'market_balances':
 
        # dictionary of currency and assets in this MARKET
        print(('Bitshares API', command))
        currency = float(ACCOUNT.balance(BitCURRENCY))
        assets = float(ACCOUNT.balance(BitASSET))
        balances = {'currency': currency, 'assets': assets}
        print (balances)
        return balances
 
    if command == 'complete_balances':
 
        # dictionary of ALL account balances
        print(('Bitshares API', command))
        raw = list(ACCOUNT.balances)
        balances = {}
        for i in range(len(raw)):
            balances[raw[i]['symbol']] = float(raw[i]['amount'])
        print (balances)
        return balances
 
    if command == 'book':
 
        # dictionary of 4 lists containing bid/ask volume/price
        print(('Bitshares API', command))
        raw = MARKET.orderbook(limit=depth)
        bids = raw['bids']
        asks = raw['asks']
        bidp = [float(bids[i]['price']) for i in range(len(bids))]
        bidv = [float(bids[i]['quote']) for i in range(len(bids))]
        askp = [float(asks[i]['price']) for i in range(len(asks))]
        askv = [float(asks[i]['quote']) for i in range(len(asks))]
        book = {'bidp': bidp, 'bidv': bidv, 'askp': askp, 'askv': askv}
        # print(book)
        print(('ask', ('%.8f' % book['askp'][0])))  # lowest ask price
        print(('bid', ('%.8f' % book['bidp'][0])))  # highest bid price
        # print(book['bidv'][0]) #highest bid volume
        # print(book['askv'][0]) #lowest ask volume
        return book
 
    if command == 'last':
 
        # the most recent transation in this MARKET
        print(('Bitshares API', command))
        raw = MARKET.ticker()['latest']
        price = float(raw)
        # print (price)
        return price
 
    if command == 'account_value':
 
        # dictionary account value in BTS BTC and USD
        print(('Bitshares API', command))
        raw = list(ACCOUNT.balances)
        balances = {}
        for i in range(len(raw)):
            balances[raw[i]['symbol']] = float(raw[i]['amount'])
        btc_value = 0
        for asset, amount in list(balances.items()):
            market_pair = 'OPEN.BTC:' + asset
            market = Market(market_pair)
            price = float(market.ticker()['latest'])
            try:
                value = amount / price
            except:
                value = 0
            if value < 0.0001:
                value = 0
            else:
                if asset != 'USD':
                    price = 1 / (price + SATOSHI)
                print((('%.4f' % value), 'OPEN.BTC', ('%.2f' % amount),
                       asset, '@', ('%.8f' % price)))
                btc_value += value
 
        market_pair = 'OPEN.BTC:USD'
        market = Market(market_pair)
        price = float(market.ticker()['latest'])
        usd_value = btc_value * price
        market_pair = 'OPEN.BTC:BTS'
        market = Market(market_pair)
        price = float(market.ticker()['latest'])
        bts_value = btc_value * price
        print((('%.2f' % bts_value), 'BTS',
             ('%.4f' % btc_value), 'OPEN.BTC',
             ('%.2f' % usd_value), 'bitUSD'))
        return bts_value, btc_value, usd_value
 
    if command == 'blocktime':
 
        current_block = CHAIN.get_current_block_num()
        blocktime = CHAIN.block_time(current_block)
        blocktimestamp = CHAIN.block_timestamp(current_block) - 18000
        now = time.time()
        latency = now - blocktimestamp
        print(('block               :', current_block))
        # print(('blocktime           :', blocktime))
        # print(('stamp               :', blocktimestamp))
        # print(('ctime(stamp)        :', time.ctime(blocktimestamp)))
        # print(('now                 :', now))
        print(('dex_rate latency    :', ('%.2f' % latency)))
        return current_block, blocktimestamp, latency
 
 
 
'''
dex('buy')
dex('sell')
dex('orders')
dex('cancel')
dex('market_balances')
dex('complete_balances')
dex('last')
dex('book')
dex('account_value')
dex('blocktime')
'''

23
from docs:

http://docs.pybitshares.com/en/latest/market.html?highlight=cancel#bitshares.market.Market.cancel
Code: [Select]
cancel(orderNumber, account=None)¶
Cancels an order you have placed in a given market.
Requires only the “orderNumber”. An order number takes the form 1.7.xxx.

Parameters: orderNumber (str) – The Order Object ide of the form 1.7.xxxx

how can I get orderNumber actively while placing an order?

how can I get orderNumber after the fact for all outstanding orders?

I attempted

Code: [Select]
print(ACCOUNT.openorders)
and

Code: [Select]
for order in MARKET.accountopenorders():
    print (order)

and this gives the order amount and price... but not orderNumber


thanks


24
Technical Support / I need some help getting started with pybitshares
« on: January 29, 2018, 06:09:06 pm »
experienced python algo trader... very good w/ quant, databases, plotting, backtesting, etc...
but least favorite task is connectivity; moving from one api to another.


just getting started w/ pybitshares:

not fully understanding what I need to do; so please ELI5

thanks,

litepresence

I just need basic trading functions:

buy/sell/cancel
list open orders
ticker
balances
orderbook



first try first fail:



Code: [Select]
from bitshares.account import Account
account = Account("xeroc")
print(account)
print(account.balances)




Code: [Select]
xyz@xyz ~/Python/EV $ python3 bitsharestest.py

Traceback (most recent call last):
  File "bitsharestest.py", line 14, in <module>
    account = Account("xeroc")
  File "/home/xyz/.local/lib/python3.4/site-packages/bitshares/account.py", line 50, in __init__
    bitshares_instance=None
  File "/home/xyz/.local/lib/python3.4/site-packages/bitshares/blockchainobject.py", line 69, in __init__
    self.bitshares = bitshares_instance or shared_bitshares_instance()
  File "/home/xyz/.local/lib/python3.4/site-packages/bitshares/instance.py", line 15, in shared_bitshares_instance
    SharedInstance.instance = bts.BitShares()
  File "/home/xyz/.local/lib/python3.4/site-packages/bitshares/bitshares.py", line 151, in __init__
    **kwargs)
  File "/home/xyz/.local/lib/python3.4/site-packages/bitshares/bitshares.py", line 180, in connect
    self.rpc = BitSharesNodeRPC(node, rpcuser, rpcpassword, **kwargs)
  File "/home/xyz/.local/lib/python3.4/site-packages/bitsharesapi/bitsharesnoderpc.py", line 23, in __init__
    super(BitSharesNodeRPC, self).__init__(*args, **kwargs)
  File "/home/xyz/.local/lib/python3.4/site-packages/grapheneapi/graphenewsrpc.py", line 64, in __init__
    self.wsconnect()
  File "/home/xyz/.local/lib/python3.4/site-packages/grapheneapi/graphenewsrpc.py", line 79, in wsconnect
    self.ws = websocket.WebSocket(sslopt=sslopt_ca_certs)
TypeError: __init__() got an unexpected keyword argument 'sslopt'



seems like no matter what I do I get this TypeError

why?  what is sslopt?  what do I have to do to fix the problem?

???

Pages: 1 [2]