Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BTC sell estimator
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
using System; namespace Rextester { public class Program { // play with these numbers: private static float btc = 1.0f; // your starting BTC amount private static float sellInterval = 1000f; // how often you want to sell as price increases private static float startPrice = 8000f; // starting price private static float goalPrice = 25000f; // price you want to be able to sell until private static float checkInterval = 10f; // make this higher or lower if you want to be finer/coarser private static float tolerance = 0.0001f; // probably don't play with this one private static float valueEachSell = 10; // probably don't play with this one public static void Main(string[] args) { float leftOver = 0f; do { leftOver = Calculate(btc); if (leftOver > tolerance) { valueEachSell += checkInterval; } } while (leftOver > tolerance); float totalCashSold = valueEachSell * ((goalPrice - startPrice) / sellInterval); float startAcctValue = btc * startPrice; float profit = ((totalCashSold / startAcctValue) - 1f) * 100f; var output1 = string.Format("Starting with {0:0.0###} BTC and the price starting at ${1},", btc, startPrice); var output1b = string.Format("Your account would be valued at ${0}", startAcctValue); var output2 = string.Format("you can sell ${0} every ${1} until price reaches ${2}", valueEachSell, sellInterval, goalPrice); var output3 = string.Format("This will equal a total of ${0} gross proceeds.", totalCashSold); var output4 = string.Format("Your profit would be ${0} / ${1} = {2:+0.00}%", totalCashSold, startAcctValue, profit); Console.WriteLine(output1); Console.WriteLine(output1b); Console.WriteLine(output2); Console.WriteLine(output3); Console.WriteLine(output4); } private static float Calculate(float startBtc) { for (float start = startPrice + sellInterval; start <= goalPrice; start += sellInterval) { float btcSold = valueEachSell / start; startBtc -= btcSold; } return startBtc; } } }
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion