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.

Messages - litepresence

Pages: [1] 2 3
Technical Support / Re: Very slow market buy with pybitshares API
« on: March 18, 2018, 03:23:05 pm »
I don't know much about VS, but I can tell you that you can greatly improve signing speed by installing
pip3 install scrypt
pip3 install secp256k1

perhaps these should auto install w/ uptick and pybitshares?

are there any other unmentioned "dependencies"?

General Discussion / 5 Node Verified Price Feed - Python
« on: March 18, 2018, 01:39:28 am »
developing here:

working under the assumption that any node can provide rogue price feeds at any given time,
I sort all nodes by latency every two minutes
then check last price on 5 low latency nodes to verify authenticity of the data every 30 seconds

5 NODE VERIFIED LAST PRICE and should be run in seperate terminals creates file nodes.txt creates file last.txt and appends to file blacklist.txt

nodes.txt is the top 10 latency sorted nodes of about 50 known nodes; updated approx every 2 minutes uses nodes.txt to get price from 5 nodes, then makes a list "prices", updated approx ever 30 seconds

then process that list of prices from 5 different nodes pseudocode:

if the spread of the prices is too wide:

    append to file blacklist.txt the list of prices and the list of nodes used to gather them

if all prices are same:
    last = latest price

elif latest price less than 2% different than mean(prices):
    last = latest price
    try: last = mode(prices)
    except: last = median(prices)

write last to last.txt

the good news:

I ran this all day on BTS/BTC and no set of 5 prices were more than 2% different... meaning I never encountered a rogue node.

the better news:

this price feed can be used with confidence to feed bots with latest price data without risk of node going stale or going rogue

the best news:

I work on bid/ask tomorrow


I am not an expert here, I'm simply an algo trader looking to integrate to the Bishares DEX environment by connecting to existing node architecture - without running my own node.  I have asked a lot of questions lately to Node Admins and have concluded there is a good deal of terminology involved that needs clarification.   There are also risks when dealing with existing nodes, that need to be mitigated.  So, please if you are an expert, chime in and I'll update this OP to summarize key points.   

This OP was initial populated with cut/paste commentary via Node Admin channel on Telegram.


some universal truisms:

- nodes are in no way uniform
- however, all nodes store all blocks
- any node can go rogue at any time
- every node is a man-in-the-middle between you and the blockchain

A node can be:



API - exposed to a network, either LAN or WAN

FULL -  nodes which provide full histories;  nodes which provide full histories; needs several tens of gigs of RAM; x5670 with 100G ram should be good for full history node

SEED - full nodes with publicly reachable p2p port

WITNESS - is a matter of votes, but you can run a witness node wich locally validates the blocks















TESTNET - testnet is actually used to determine if it's mainnet or testnet








FAKE - fake.automatic-selection is a hard-coded psuedo server

BITSHARES OFFICIAL - deployed with bitshares UI

CRYPTOBRIDGE OFFICIAL - deployed with cryptobridge UI

UP TO DATE - has a head block that is less than 3 seconds old

STALE - has a head block that is greater than 3 seconds old



VERSION 171105a - if there are many wicks in price chart, it's on this version

pre-VERSION 1802xx - if owner key signature is not able to change active permissions, it's before 1802xx

ROGUE - a node can delay, refuse, or reorder your buy/sell/cancel or other requests.   A rogue node can also return inaccurate information to all or any one individual.  A rogue node can NOT modify or create a buy/sell/cancel operation on your behalf.  A rogue node can provide false account ID in an attempt to get you to send funds to bad address.




CLI - command line interface
FAUCET - a pool of funds used to pay the registration fee for the new accounts, there are currently several public faucets up




General Discussion / Re: When stop loss
« on: March 17, 2018, 03:05:51 am »
check here:

Wrapper for Common PyBitshares DEX Algo Trading API Calls

should be very easy to implement, like this:

Code: [Select]
while 1:
    if dex('last') < stoploss:

call it done

General Discussion / Re: (Python) latency sorted Bitshares nodes
« on: March 17, 2018, 12:03:24 am »
I've made considerable progress on this script check the github in OP

I've live tested it in a while loop 24 hours and it maintains an output file of latency tested "nodes.txt"

Code: [Select]
def nodes(timeout=20, pings=999999, crop=99, noprint=False, write=False,
          include=False, exclude=False, suffix=True, master=False):

    # timeout : seconds to ping until abort per node
    # pings   : number of good nodes to find until satisfied (0 none, 999 all)
    # suffix  : checks each node for no suffix plus with /ws or /wss
    # noprint : disables printing, only returns list of good nodes
    # master  : check only nodes listed in bitshares/ui/master
    # crop    : return only best nodes
    # write   : maintains an output file nodes.txt with list of best nodes

h/t @ Alex M

resolved was able to pass:

Code: [Select]

Code: [Select]
chain = Blockchain(bitshares_instance=BitShares(n, num_retries=0), mode='head')
I had given up on this early on because I tried this without success:

Code: [Select]
chain = Blockchain(bitshares_instance=BitShares(n), num_retries=0, mode='head')

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

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:

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)
                # websocket.enableTrace(True)
       = websocket.WebSocketApp(
            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:
                        "Lost connection to node during wsconnect(): %s (%d/%d) "
                        % (self.url, cnt, self.num_retries) +
                        "Retrying in %d seconds" % sleeptime

            except KeyboardInterrupt:
       = False

            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: = False

where the user could command:

Code: [Select]

attempt = 1
while attempt:


      # 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
          # 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:

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

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

does not catch

Perhaps it's good tool for pybitshares. Can you make a PR in github? Or even create your own tool set.

I've decided to maintain my own tool set.


Code: [Select]
                   Version 0, March 1765


1) If it bears an official stamp, prepare to throw it overboard.

General Discussion / Re: More Nodes....
« on: March 12, 2018, 08:11:35 pm »

Please vote for this node "neoreel-1" currently ranked 98 with 50 millions votes...

where is this ranking listed?

General Discussion / Re: More Nodes....
« on: March 12, 2018, 12:05:00 am »
these 34 are known to be active with ping less than 5 seconds as of today, sorted by lowest latency to east coast US:

connected to wss:// with latency 1.17

['wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://']

General Discussion / (Python) latency sorted Bitshares nodes
« on: March 11, 2018, 05:53:11 pm »
Update:  Developing here:

An "official" list of public nodes is here:

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

    uri = ''
    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

Code: [Select]
print (nodes())

['wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://', 'wss://']

Code: [Select]
from import Market
from bitshares import BitShares

MARKET = Market(BitPAIR, bitshares_instance=BitShares(nodes()))

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

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.

Stakeholder Proposals / Re: Legal Council about BTS and No-action
« on: March 10, 2018, 09:33:55 pm »
New Worker Proposal

With this worker, we (the bitshares blockchain foundation) would like to fund this project to seek legal clarity and presentation for BTS holders and regulators.

Additionally to an opinion letter of a prestigious legal council,
we also seek a non-action letter by the United States Securities and Exchange Commission (SEC), the prototype for many regulators in the world.

This should be two separate workers.

#1 seems many agree on urgent and important, wise

#2 we all have varying outlooks, SEC letter is a to voting for legal council

maybe we should #1 and ask the experts if we should #2

What is this?

This is a bot framework for algo trading the Bitshares DEX with an awareness of outside markets.

You get numpy arrays of cryptocompare data to process yourself, I've also included a finite state machine that breaks the market into 4 states:

bull (selloff, support)
bear (resistance, despair)

out of the box it trades the BTS/BTC pair for 30X over the past year of data per backtest

I also offer a 500X pay per view version.

I have multiple machines mining input thresholds for various altcoin/bitcoin pairs.   The AI runs about 500k backtests for each altcoin and I sell these thresholds for you to trade on the DEX via  There is nothing to stop you from running a few backtests and creating your own thresholds or even stand alone algos on with this framework.

My goals are:

Make services which provide bot trading via website (like cryptotrader, tradewave, etc. ) obsolete.
Encourage CEX algo traders to move to Bitshares DEX by simplifying API connectivity.
Require absolute minimum module dependencies.
Create a performance aligned altcoin trading strategy back testing environment that is open source and runs locally.

features and dependencies from the script banner:

Code: [Select]
    ''' FEATURES '''
   ALT/BTC data from as signal
   Bitshares DEX open.ALT/open.BTC for trading
   - Play simple effective 4 state 50 day cross
       - uses live 2h arrays to generate moving averages
       - ma1xma2 is about 17x50 day simple moving average cross
       - cross plus +/- threshold changes state logic from bull to bear
       - Bull Logic
           buy 17 day support
           sell 17 day x ~1.5 selloff
       - Bear logic
           sell 17 day resistance
           buy 17 day x ~0.75 despair
       - dynamic stoploss upon market shift
       - approximately 7-20 day trade frequency depending upon pair
       - announces machine state on plot
   - Make Markets, Close Margins, Support Trends
   - Iceberg entry and exit
   - Bot runs local
   - Backtest Engine Included
   - Maintains storage from backtest to live session
Code: [Select]
   python 3.4
   matplotlib 1.4

Pages: [1] 2 3