Author Topic: How you can help the economy: Arbitrage for programmers  (Read 4586 times)

0 Members and 1 Guest are viewing this topic.

Offline yellowecho

I have a little programming experience but don't feel comfortable enough to execute the code (and risk placing incorrect orders stuck in a while loop).  Could someone comment each line of code and further explain the details?  For instance, what does the function 'get_true_price()' actually do?  Where does it get that price and what does the function do?  Does it pull from an internal price feed?  And from the looks of it SYMBOL and SPREAD are the only variables that need to be modified to 'fill in the gaps'.. am I reading that correctly?  Gah, I'm such a n00b  :D
696c6f766562726f776e696573

Offline maqifrnswa

  • Hero Member
  • *****
  • Posts: 661
    • View Profile
Many here are technically inclined, but not necessarily financially experienced. Right now bitsharesx is still in its infancy, and as such has small liquidity. That creates an opportunity for profit by arbitrage. Such profit also injects liquidity - so it's a win-win.

Here are two quick ways you can participate:
1) Inter-exchange arbitrage If you know the "true" market rate for BTSX in dollars (e.g., from coinmarketcap/bter/btc38 prices), you can trade the spread between such a "true" price and the price trading for BTSX:USD in bitsharesx:
fill in the gaps...

Code: [Select]
while True:
    time.sleep(2)
    new_price = get_true_price()
    sec_since_update += 2
    if abs(new_price - last_price) / last_price > (SPREAD / 3):
        log("Price moved  -  old:  %f   new:  %f" % (last_price, new_price))
        log("Seconds since previous update:  %d" % sec_since_update)

        client.cancel_all_orders("USD", SYMBOL)
        client.wait_for_block()
        usd_balance = client.get_balance("USD")
        btsx_balance = client.get_balance(SYMBOL)
        client.submit_bid(0.3*(usd_balance * new_price), SYMBOL, new_price * (1+SPREAD), "USD")
        client.submit_ask(0.3*btsx_balance, SYMBOL, new_price * (1-SPREAD), "USD")
        last_price = new_price

2) Three-legged arbitrage If you can trade BTSX:BitUSD (bitsharesx), BitUSD:BTC (https://bter.com/trade/btc_bitusd), and BTC:BTSX (https://bter.com/trade/BTSX_BTC), you can use arbitrage to generate more coins if the exchange rates are not "correct":
right now (1400 UTC 2014-08-27) if I start with 1 BTSX and convert it to BTC then BITUSD then back to BTSX I end up with
1* 0.0000710 BTC/BTSX * 551.00 BitUSD/BTC * 26.698008 BTSX/USD = 1.044452771
That means if there are no fees, and I just buy one BTC then use that to buy BitUSD thenuse that to buy BTSX, and I end up with 4% more BTSX then I started with, free money.

3) Discount trading just check this out, and act accordingly:
https://bter.com/trade/BITUSD_USD
maintains an Ubuntu PPA: https://launchpad.net/~showard314/+archive/ubuntu/bitshares [15% delegate] wallet_account_set_approval maqifrnswa true [50% delegate] wallet_account_set_approval delegate1.maqifrnswa true