Bitcoin Forum
December 09, 2016, 07:48:38 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2] 3 »  All
  Print  
Author Topic: Bitcoinica Helper (userscript)  (Read 4191 times)
proudhon
Legendary
*
Offline Offline

Activity: 1148



View Profile
January 14, 2012, 03:03:22 PM
 #21

Working for me too on both my machines.  Though, yesterday to test it out I took a small long position that I was pretty sure would get zhoutonged.  Your helper told me the zhoutong price was around 6.39, but my position held until the low 30s.
1481269718
Hero Member
*
Offline Offline

Posts: 1481269718

View Profile Personal Message (Offline)

Ignore
1481269718
Reply with quote  #2

1481269718
Report to moderator
1481269718
Hero Member
*
Offline Offline

Posts: 1481269718

View Profile Personal Message (Offline)

Ignore
1481269718
Reply with quote  #2

1481269718
Report to moderator
1481269718
Hero Member
*
Offline Offline

Posts: 1481269718

View Profile Personal Message (Offline)

Ignore
1481269718
Reply with quote  #2

1481269718
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481269718
Hero Member
*
Offline Offline

Posts: 1481269718

View Profile Personal Message (Offline)

Ignore
1481269718
Reply with quote  #2

1481269718
Report to moderator
1481269718
Hero Member
*
Offline Offline

Posts: 1481269718

View Profile Personal Message (Offline)

Ignore
1481269718
Reply with quote  #2

1481269718
Report to moderator
M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
January 14, 2012, 03:39:49 PM
 #22

I'm using the calculations posted by zhoutong, so I think they're correct.

There's a small bug in the code though that may affect the result of calculations a bit - it takes only first two digits from the bid/ask price (it's because in the code they are split up to make the rest of digits gray). On small positions this could show up as a visible difference, and you just saw it.

I've fixed that error and pushed a new version. Remember to uninstall the old one, because you can end up with two different versions running at the same time.

EDIT: It's not that easy to actually test that. I've created a 10:1 leveraged 9.5 BTC position (having 1 BTC on account) and here's the result:



I should've shorted, because I don't think we'll hit 6.2 again Cheesy
Zotia
Full Member
***
Offline Offline

Activity: 120


View Profile
January 16, 2012, 03:30:10 PM
 #23

I have a small feature request.  I would like to be able to click on the quantity buttons even if I don't have enough money to buy.  I want this because:
-Sometimes I want to sell using those buttons.
-Sometimes I want to buy more BTC after the price goes up.

Needing to refresh the page or enter the number manually is rather annoying (when those buttons are already there but just grayed out).




I'm using the calculations posted by zhoutong, so I think they're correct

I found your problem.


This:
Code:
// Long
if (amount > 0)
min_price = Math.round((ask - ((net_value - maintenance)/(amount + btc))) * 100) / 100;

// Short
else
min_price = Math.round((bid - ((net_value - maintenance)/(amount - btc))) * 100) / 100;

Should be this:
Code:
// Long
if (amount > 0)
min_price = Math.round((bid - ((net_value - maintenance)/(amount + btc))) * 100) / 100;

// Short
else
min_price = Math.round((ask - ((net_value - maintenance)/(amount - btc))) * 100) / 100;

(Notice the change to "bid" and "ask").


It seems to fix it.


To test it to see if it was accurate, I changed it like this:


Code:
// Long
if (amount > 0)
min_price = (bid - ((net_value - maintenance)/(amount + btc));

// Short
else
min_price = (ask - ((net_value - maintenance)/(amount - btc));
(Notice the removal of "Math.round").


This allowed me to have it display all of the digits it uses.

I tested it for a 10:1 account:

-Manually doing the calculation resulted in 6.665561463414634146341463414635
-Using the test script resulted in 6.665561463414635

So it's accurate to 15 digits.  (By accurate, I mean it yields the same result as doing it manually).



Now that it works correctly, I wanted it to show 4 digits instead of 2, so I changed it like this.

Code:
// Long
if (amount > 0)
min_price = Math.round((bid - ((net_value - maintenance)/(amount + btc))) * 10000) / 10000;

// Short
else
min_price = Math.round((ask - ((net_value - maintenance)/(amount - btc))) * 10000) / 10000;

(Notice the change from "100" to "10000").




With this change, it will now display the correct minimum price to 4 digits.




PS: Thank you for making this script.  Grin
M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
January 16, 2012, 04:02:17 PM
 #24

Wow, thanks for the correction Smiley. I've incorporated the changes into the script. I've also added a function to enable all "quick pick" buttons.
Zotia
Full Member
***
Offline Offline

Activity: 120


View Profile
January 16, 2012, 05:59:09 PM
 #25

Wow, thanks for the correction Smiley. I've incorporated the changes into the script. I've also added a function to enable all "quick pick" buttons.

Wow, that was quick!


Thank you!  Grin
Maged
Legendary
*
Offline Offline

Activity: 1260


View Profile
January 16, 2012, 07:15:52 PM
 #26

Wow, thanks for the correction Smiley. I've incorporated the changes into the script. I've also added a function to enable all "quick pick" buttons.
You forgot to bump the version number in the OP. Don't worry, I did it for you.

Oh, and if you ever need any help on this, I'd be happy to assist you.

M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
January 16, 2012, 09:12:30 PM
 #27

You forgot to bump the version number in the OP. Don't worry, I did it for you.

Oh, and if you ever need any help on this, I'd be happy to assist you.

Thanks! This is nice about Bitcoin community, everybody tries to help to get better Bitcoin ecosystem Smiley.
Zotia
Full Member
***
Offline Offline

Activity: 120


View Profile
January 18, 2012, 02:26:00 AM
 #28

I found another bug.


Sometimes, the BTC/USD prices are updated separately from the panel on the right.  When this happens, the "net value" is based upon a BTC/USD price that was updated at a different time.  This means that the "Min price" will be changed.   The "Min price" should never change.


It actually had a significant effect on the "Min price" today, due to the volatility.  At one point, the value was inaccurate off by over 0.10 BTC/USD.



I'm not sure how this could be fixed.
cypherdoc
Legendary
*
Offline Offline

Activity: 1764



View Profile
January 18, 2012, 02:29:02 AM
 #29

I found another bug.


Sometimes, the BTC/USD prices are updated separately from the panel on the right.  When this happens, the "net value" is based upon a BTC/USD price that was updated at a different time.  This means that the "Min price" will be changed.   The "Min price" should never change.


It actually had a significant effect on the "Min price" today, due to the volatility.  At one point, the value was inaccurate off by over 0.10 BTC/USD.



I'm not sure how this could be fixed.

wonderful.
MelMan2002
Sr. Member
****
Offline Offline

Activity: 434



View Profile
January 18, 2012, 11:20:07 PM
 #30

Nice script!
M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
January 23, 2012, 09:28:44 PM
 #31

New version of the script

Added feature: shows you how much BTC are your dollars worth and vice-versa, when you hover your mouse over these values:



Please post some more suggestions how we could improve Bitcoinica and I'll see what I can do Smiley.
stochastic
Hero Member
*****
Offline Offline

Activity: 532


View Profile
January 23, 2012, 09:35:42 PM
 #32

New version of the script

Added feature: shows you how much BTC are your dollars worth and vice-versa, when you hover your mouse over these values:



Sweet.  Could you add a function calculate the user's current margin call rate?

Introducing constraints to the economy only serves to limit what can be economical.
vokain
Legendary
*
Offline Offline

Activity: 1610


V.V.V.V.V.


View Profile
January 24, 2012, 02:21:33 AM
 #33

someone check the code if it doesn't track our positions, anddd donation link/adderss? This is very useful, and I know some appreciative donations would probably incentivize you for improvements too Smiley

...مكتوب
Escape the plutocrats’ zanpakutō, Flower in the Mirror, Moon on the Water: brave “the ascent which is rough and steep” (Plato).
Maged
Legendary
*
Offline Offline

Activity: 1260


View Profile
January 24, 2012, 03:31:48 AM
 #34

someone check the code if it doesn't track our positions
Done. Version 1.2.0 is completely safe, as of this message.

@M4v3R: You can get rid of line 12-20. Mootools makes unsafeWindow obsolete. I'm glad to see that you moved away from unsafeWindow, though.

M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
January 24, 2012, 06:55:59 AM
 #35

@Maged: Yeah, the code for unsafeWindow is obsolete now. I've also changed "addMootools" function to just "addScript", because it wasn't loading Mootools (I wanted to do that in the first place, but I've changed my mind), just adding the script to main page body. Thanks for the suggestion.
elux
Legendary
*
Offline Offline

Activity: 1454



View Profile
February 13, 2012, 10:58:23 AM
 #36

Did bitcoinica swaps break the script? I got wrong data and had to disable it.
legitnick
Hero Member
*****
Offline Offline

Activity: 532



View Profile WWW
February 13, 2012, 11:04:10 AM
 #37

Did bitcoinica swaps break the script? I got wrong data and had to disable it.
Yeah my base price is 5.40 and it says my liquidation price is at 5.9 on my long position.

5 BITCOIN RAFFLE GIVEAWAY
"I dont lift" - Lord Furrycoat
waspoza
Hero Member
*****
Offline Offline

Activity: 602


Firstbits: 1waspoza


View Profile
February 13, 2012, 11:08:25 AM
 #38

Did bitcoinica swaps break the script? I got wrong data and had to disable it.

Yup, looks broken to me.
M4v3R
Hero Member
*****
Offline Offline

Activity: 607



View Profile
February 13, 2012, 11:20:47 AM
 #39

Yeah, I guess it could break the script if they've changed HTML on the site. I'll look at this later today.
MelMan2002
Sr. Member
****
Offline Offline

Activity: 434



View Profile
February 14, 2012, 02:09:08 AM
 #40

A quick fix for those interested (not sure if it is complete):
Change line 75 from:
net_value = USER_ParseCurrency(account_data[13].innerHTML);
to:
net_value = USER_ParseCurrency(account_data[15].innerHTML);

and Change line 76 from:
maintenance = USER_ParseCurrency(account_data[15].innerHTML);
to:
maintenance = USER_ParseCurrency(account_data[17].innerHTML);
Pages: « 1 [2] 3 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!