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: How you can help the economy: Arbitrage for programmers  (Read 548 times)

0 Members and 1 Guest are viewing this topic.

Offline maqifrnswa

  • Hero Member
  • *****
  • Posts: 661
    • View Profile
How you can help the economy: Arbitrage for programmers
« on: August 27, 2014, 01:55:53 PM »

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

Offline yellowecho

Re: How you can help the economy: Arbitrage for programmers
« Reply #1 on: August 27, 2014, 02:44:07 PM »
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
Re: How you can help the economy: Arbitrage for programmers
« Reply #2 on: August 27, 2014, 02:50:04 PM »
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

The gaps include writing the functions in that skeleton, including get_true_price() and all the client.*. It's up to the programmer to choose where and how to get the price; there is no internal price feed for that.
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

Offline biophil

  • Hero Member
  • *****
  • Posts: 774
  • Incentives run the world
    • View Profile
  • BTS: zebulon
Re: How you can help the economy: Arbitrage for programmers
« Reply #3 on: August 27, 2014, 02:50:41 PM »
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

I'm in the same boat. It's killing me to have my BTSX stake just sitting around when arbitrage opportunities are growing on trees. I'd tip heavily to get my hands on a nice modular arbitrage tool.

Sent from my SCH-S720C using Tapatalk 2


Offline soniq

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Re: How you can help the economy: Arbitrage for programmers
« Reply #4 on: August 27, 2014, 02:52:16 PM »
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

I'm in the same boat. It's killing me to have my BTSX stake just sitting around when arbitrage opportunities are growing on trees. I'd tip heavily to get my hands on a nice modular arbitrage tool.

Sent from my SCH-S720C using Tapatalk 2

I second that
Pr7V9GUm59dtKWXG6RJSymPsyCaCKWwNEj
Soniq on Bitcointalk -- Verified
Bitshares btsx:soniq

Offline bytemaster

Re: How you can help the economy: Arbitrage for programmers
« Reply #5 on: August 27, 2014, 02:56:57 PM »
Keep in mind that the arb bot probably needs to factor in relative short/long demand... the strategy that works "long term" (flux around "true price") is not the best "short term" which is "flux around premium".   

The "premium" we see right now suggests that the rate of return demanded on BitUSD is about 14% between "now" and "when the peg hits parity".     
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline biophil

  • Hero Member
  • *****
  • Posts: 774
  • Incentives run the world
    • View Profile
  • BTS: zebulon
Re: How you can help the economy: Arbitrage for programmers
« Reply #6 on: August 27, 2014, 02:58:55 PM »
Keep in mind that the arb bot probably needs to factor in relative short/long demand... the strategy that works "long term" (flux around "true price") is not the best "short term" which is "flux around premium".   

The "premium" we see right now suggests that the rate of return demanded on BitUSD is about 14% between "now" and "when the peg hits parity".   

Agreed, but zero-delay arbitrage across exchanges works no matter what your time horizon is.

Sent from my SCH-S720C using Tapatalk 2


Offline maqifrnswa

  • Hero Member
  • *****
  • Posts: 661
    • View Profile
Re: How you can help the economy: Arbitrage for programmers
« Reply #7 on: August 27, 2014, 03:19:10 PM »
Agreed, but zero-delay arbitrage across exchanges works no matter what your time horizon is.

This is what I'm thinking - exchanges have liquidity, bitsharesx doesn't at the moment, so let's inject some of that exchange liquidity into bitsharesx using zero-delay arb.
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

Offline bytemaster

Re: How you can help the economy: Arbitrage for programmers
« Reply #8 on: August 27, 2014, 03:20:18 PM »
Agreed, but zero-delay arbitrage across exchanges works no matter what your time horizon is.

This is what I'm thinking - exchanges have liquidity, bitsharesx doesn't at the moment, so let's inject some of that exchange liquidity into bitsharesx using zero-delay arb.

+1... lots of financial incentive out there for people to develop this :)
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline bitmeat

  • Hero Member
  • *****
  • Posts: 1116
    • View Profile
Re: How you can help the economy: Arbitrage for programmers
« Reply #9 on: August 27, 2014, 03:20:50 PM »
Be mindful to take into account liquidity and exchange fees.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12065
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: How you can help the economy: Arbitrage for programmers
« Reply #10 on: August 27, 2014, 06:20:40 PM »
+1... lots of financial incentive out there for people to develop this :)
... and not release the code ..

a.k.a ... not deliver until unprofitable ... (reminds you of sth.?)
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline luckybit

Re: How you can help the economy: Arbitrage for programmers
« Reply #11 on: August 27, 2014, 06:52:26 PM »
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

How are we supposed to use the code? Does it connect to the RPC API or what?
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline luckybit

Re: How you can help the economy: Arbitrage for programmers
« Reply #12 on: August 27, 2014, 06:55:11 PM »
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

I'm in the same boat. It's killing me to have my BTSX stake just sitting around when arbitrage opportunities are growing on trees. I'd tip heavily to get my hands on a nice modular arbitrage tool.

Sent from my SCH-S720C using Tapatalk 2

I second that

We need a scripting language built into the interface somehow. It's that simple.
The more complicated it is to do the less people there will be doing it.

I can handle C++ but someone has to make a blog like "how to make bots using Bitshares API".

Then do a brief run through of the different functions. Best way to do it is let us input our scripts or our code directly into Bitshares. If it has to deal with compiling and the formulas for arbitrage aren't documented then less people will make bots.

+1... lots of financial incentive out there for people to develop this :)
... and not release the code ..

a.k.a ... not deliver until unprofitable ... (reminds you of sth.?)

I'm not even asking about the code. I want to know how to interact with the API so I can write my own code. Also I want the formulas which make up the underlying basis of the arbitrage bots.

As far as I know it gets a set of price feeds and compares them, then trades on the difference. The code itself is very simple for any programmer. It looks like it's using RPC API http://bitshares.org/documentation/group__rpc__api.html

I will see if I can write a script myself later today.

« Last Edit: August 27, 2014, 07:01:52 PM by luckybit »
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12065
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline maqifrnswa

  • Hero Member
  • *****
  • Posts: 661
    • View Profile
Re: How you can help the economy: Arbitrage for programmers
« Reply #14 on: August 28, 2014, 09:07:01 PM »
checkout:
https://bitsharestalk.org/index.php?topic=5562.0;all

Some of my own code (no market, just interface)
https://github.com/xeroc/pytshares/blob/master/btsrpcapi.py

awesome, thanks - great demonsrtation of RPC calls

I wanted to modify the three-legged inter-exchange arbitrage to demonstrate another common case (one we're in right now)

bidask
BTC/BTSX0.00006550.000066
BitUSD/BTC540600
BTSX/BitUSD26.527

this is the current bter and bitsharesx snapshot. There is an opportunity for free, instant money there - while also evening out liquidity
1) the spread of BitUSD/BTC is so large that if you place a bid that is fulfilled less than    561.1672278339 or an ask greater than 576.1198329252, and you 2) move the exact same amount of what you purchased through the BTC->BTSX->BitUSD or BitUSD->BTSX->BTC chain, you will end up with more BitUSD and BTC than you started with, instantly.

« Last Edit: August 28, 2014, 09:10:20 PM by maqifrnswa »
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

 

Google+