Commit 6f37fccb authored by Gampe Sebastian's avatar Gampe Sebastian
Browse files

initial upload

parent f6a31560
# FairCoin FreeVision
# FairCoin FreeVision ( proposal ) Whitepaper
## Introduction
FairCoin exists since 2014 with the vision of a fair and cooperative working economy. All informations about it can find under https://fair-coin.org the base website of FairCoin.
Main part of FairCoin is the price mechanism to stableize the price and prevent the pump and dump and the effects to the fair economy.
Another important part is the proof-of-cooperation algorithm where specific nodes create the blocks within all transactions by a round-robin procedure and almost without a fee. This proof-of-cooperation algorithm saves ressources and scales up better than a proof-of-work or proof-of-stake system as other cryptocurrencies use.
The reality shows us that the existing price mechanism is very limited and creates some needs that is hard to fulfill. In principle the system depends on investors that put new capital into the system that secures the liquidity that is necessary to hold the price stable and on level.
During the creation of this whitepaper the current market price of FairCoin is 0.10€ but the official price is still at 1.20€
FairCoin FreeVision don't want to call the price mechanism in question but want add another price mechanism that works everytime and in every market and doesn't depends on new investors or capital.
We want ADD other possibilities to FairCoin but we don't want and will NEVER fork the FairCoin blockchain. We don't want compete against the existing mechanism and infrastructure but we want also support it and maybe we can improve the whole FairCoin ecosystem with our ideas.
We see FairCoin at the moment primary driven und decided by Fair.Coop as an eco-human-centric but idealistic movement.
But we see also similar but other movements like komun.org as an eco-human-centric but with a higer focus to decentralization.
We think that if we want to create a powerful cryptocurrency that could become a alternative to fiat money or Bitcoin then we need to spread FairCoin and invite people that for example want support a fair economy but don't want to go the idealistic way but prefer more pragmatism and realism.
We want make compromises instead to follow only the one way if it brings us a step forward.
FairCoin FreeVision should be understood as a part of FairCoin community that don't want ignore the free market but work with it and find a middle-way between liquidity and stability.
We also want think about decentralization, about possible improvements of the proof-of-cooperation algorithm or the way to process the exchanges from fiat to FairCoin or FairCoin to fiat.
FairCoin FreeVision is made for eco-libertarians or progessivists.
## The price mechanism
Price adjustments should be not made by humans in assemblies because we think that it works only in a very low level but cant portray the global movement or community of thousands of FairCoin members.
It is crazy that a dozen of members decides about the new price but the community has 500 or more members.
We think that the price adjustments should be done by automatism.
Our support price will calculated by this formula
support price = integer( ( free market price – 0.01€ ) * 10 ) / 10
Examples: ( market price / our support price )
* 0.10€ / 0.05€
* 0.11€ / 0.10€
* 0.12€ / 0.10€
* ..
* 0.20€ / 0.10€
* 0.21€ / 0.20€
* ..
* 0.30€ / 0.20€
* 0.31€ / 0.30€
The support price is everytime lower than the free market price. So we can prevent arbitrage trading and the liquidity problematic.
## The exchange system
We change OtherCurrencies to FairCoin to free market price but FairCoin to OtherCurrencies only to support price.
Example:
If the market price is 0.20€ we change FairCoin to Other to 0.10€ but Other to FairCoin to 0.20€
So arbitrage trading can prevented and in opposite the service itself do arbitrage trading and the win of aribtrage trading will go to the existing FairCoin system and supports the official price of 1.20€ or we invest the win into technical improvements of FairCoin where all FairCoiner will profit.
Our exchange system will be open and transparent for everyone ( with respect to privacy to the members ) and processed by p2p exchanges made by authorized supporters.
### The slot system
To make the exchanges efficient to handle we uses a slot system to organize all exchanges.
Every slot has same size for example 100€. So we would support only exchanges in 100€ steps.
The maximum number of slots will calculated by promised slots from supporters.
To decentralize it it is possible that small FairCoiner can become a supporter and for example support only 1 slot per month.
The risk is very low for all supporters because of the price spread.
Every user ( collective or individual ) can request an exchange and the system calculates a score and assigns the slots to the requestors.
Merchants and companies first, individuals last because we don't want support individual speculations and think that every individual should only buy so much FairCoin he could lose in worst case.
Users with lower amount of assigned slots in past will prefered but all users will be respected in the calculation.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
function json_load( url ){
var json = null;
$.ajax({
'async': false,
'global': false,
'cache': false,
'url': url,
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
}
//https://www.coinexchange.io/api/v1/getmarketsummary?market_id=200
//https://www.coinexchange.io/api/v1/getorderbook?market_id=200
$( document ).ready(
function() {
get_data();
}
);
function get_data(){
var DATA=json_load('functions/get_data.php');
console.log(DATA);
$('#fv_bid').html( DATA.fv_bid );
$('#fm_bid').html( DATA.fm_bid.toString().slice(0,-1) + '<sub>' + DATA.fm_bid.toString().slice(-1) + '</sub>' );
$('#fm_ask').html( DATA.fm_ask.toString().slice(0,-1) + '<sub>' + DATA.fm_ask.toString().slice(-1) + '</sub>' );
$('#fv_ask').html( DATA.fv_ask );
$('#conf').html( JSON.stringify( DATA.config).replace(/\,/g,'<br>').replace(/\"|\{|\}/g,'').replace(/\:/g,' = ') );
$('#formulas').html( JSON.stringify( DATA.formulas).replace(/\,/g,'<br>').replace(/\"|\{|\}/g,'').replace(/\:/g,' = ') );
var tmp='';
DATA.history.forEach(
function(v,i){
var V=v.split(/,/g);
if( V.length > 1 ){
tmp+='<div class="row">'
tmp+='<div class="col">'+(( i == 0 ) ? V[0] : new Date(V[0]*1000).toJSON().slice(0,16).replace(/T/g,' '))+'</div>';
tmp+='<div class="col">'+V[1]+'</div>';
tmp+='<div class="col">'+V[2]+'</div>';
tmp+='<div class="col">'+V[3]+'</div>';
tmp+='<div class="col">'+V[4]+'</div>';
tmp+='<div class="col">'+V[5]+'</div>';
tmp+='<div class="col">'+V[6]+'</div>';
tmp+='</div>';
}
}
);
$('#history').html(tmp);
}
{
"ask": 3006.62,
"bid": 3003.98,
"last": 2998.73,
"high": 3032.12,
"low": 2993.19,
"open": {
"hour": 2998.43,
"day": 3015.52,
"week": 3114.24,
"month": 3337.50,
"month_3": 5597.74,
"month_6": 6347.26,
"year": 7653.92
},
"averages": {
"day": 3010.10,
"week": 3010.35,
"month": 3041.64
},
"volume": 41219.40837125,
"changes": {
"price": {
"hour": 0.30,
"day": -16.79,
"week": -115.51,
"month": -338.77,
"month_3": -2599.01,
"month_6": -3348.53,
"year": -4655.19
},
"percent": {
"hour": 0.01,
"day": -0.56,
"week": -3.71,
"month": -10.15,
"month_3": -46.43,
"month_6": -52.76,
"year": -60.82
}
},
"volume_percent": 16.31,
"timestamp": 1549299565,
"display_timestamp": "2019-02-04 16:59:25",
"display_symbol": "BTC-EUR"
}
\ No newline at end of file
{"success":"1","request":"\/api\/v1\/public\/getorderbook","message":"","result":{"SellOrders":[{"Type":"sell","Price":"0.00003369","OrderTime":"2019-02-04 16:47:47","Quantity":"194.57794856"},{"Type":"sell","Price":"0.00003370","OrderTime":"2019-02-03 15:12:14","Quantity":"276.76128607"},{"Type":"sell","Price":"0.00003372","OrderTime":"2019-02-02 19:54:55","Quantity":"153.00000000"},{"Type":"sell","Price":"0.00003375","OrderTime":"2019-02-02 19:56:18","Quantity":"248.00000000"},{"Type":"sell","Price":"0.00003378","OrderTime":"2019-02-02 12:59:29","Quantity":"515.11888539"},{"Type":"sell","Price":"0.00003379","OrderTime":"2019-01-31 12:41:52","Quantity":"30.00000000"},{"Type":"sell","Price":"0.00003400","OrderTime":"2018-12-03 18:36:41","Quantity":"300.00000000"},{"Type":"sell","Price":"0.00003400","OrderTime":"2019-02-04 01:20:32","Quantity":"550.00000000"},{"Type":"sell","Price":"0.00003449","OrderTime":"2018-12-03 18:37:11","Quantity":"300.00000000"},{"Type":"sell","Price":"0.00003470","OrderTime":"2019-02-02 13:47:46","Quantity":"700.00000000"},{"Type":"sell","Price":"0.00003487","OrderTime":"2019-01-10 22:52:47","Quantity":"1639.72902558"},{"Type":"sell","Price":"0.00003488","OrderTime":"2019-01-07 20:28:07","Quantity":"800.00000000"},{"Type":"sell","Price":"0.00003500","OrderTime":"2018-12-14 00:02:01","Quantity":"700.00000000"},{"Type":"sell","Price":"0.00003500","OrderTime":"2018-12-27 22:32:13","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00003500","OrderTime":"2019-01-27 19:00:18","Quantity":"1000.00000000"},{"Type":"sell","Price":"0.00003500","OrderTime":"2019-02-03 23:16:47","Quantity":"1094.77323044"},{"Type":"sell","Price":"0.00003500","OrderTime":"2019-02-04 16:14:22","Quantity":"2600.00000000"},{"Type":"sell","Price":"0.00003501","OrderTime":"2018-12-03 18:37:48","Quantity":"292.48060445"},{"Type":"sell","Price":"0.00003580","OrderTime":"2019-01-10 06:34:09","Quantity":"500.00000000"},{"Type":"sell","Price":"0.00003595","OrderTime":"2019-01-15 08:24:15","Quantity":"400.00000000"},{"Type":"sell","Price":"0.00003599","OrderTime":"2018-12-28 12:22:25","Quantity":"12.00000000"},{"Type":"sell","Price":"0.00003600","OrderTime":"2018-12-13 20:42:02","Quantity":"225.98989691"},{"Type":"sell","Price":"0.00003600","OrderTime":"2018-12-27 22:32:34","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00003601","OrderTime":"2018-11-27 09:29:08","Quantity":"200.00000000"},{"Type":"sell","Price":"0.00003698","OrderTime":"2018-12-07 14:46:36","Quantity":"2000.00000000"},{"Type":"sell","Price":"0.00003700","OrderTime":"2018-12-03 17:06:26","Quantity":"500.00000000"},{"Type":"sell","Price":"0.00003700","OrderTime":"2018-12-21 17:40:19","Quantity":"1500.00000000"},{"Type":"sell","Price":"0.00003700","OrderTime":"2019-01-20 05:09:57","Quantity":"921.56527009"},{"Type":"sell","Price":"0.00003701","OrderTime":"2018-11-27 09:29:28","Quantity":"200.00000000"},{"Type":"sell","Price":"0.00003800","OrderTime":"2018-12-03 03:18:16","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00003800","OrderTime":"2018-12-11 21:49:20","Quantity":"1000.00000000"},{"Type":"sell","Price":"0.00003800","OrderTime":"2019-01-24 16:11:38","Quantity":"966.18607997"},{"Type":"sell","Price":"0.00003890","OrderTime":"2018-12-03 18:30:13","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00003895","OrderTime":"2018-12-03 18:29:37","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00003895","OrderTime":"2018-12-13 10:21:09","Quantity":"40.27452133"},{"Type":"sell","Price":"0.00003899","OrderTime":"2018-12-07 14:47:04","Quantity":"5000.00000000"},{"Type":"sell","Price":"0.00003901","OrderTime":"2018-11-23 14:28:13","Quantity":"10000.00000000"},{"Type":"sell","Price":"0.00003950","OrderTime":"2018-11-30 20:35:03","Quantity":"235.00000000"},{"Type":"sell","Price":"0.00003970","OrderTime":"2018-11-30 20:35:40","Quantity":"200.00000000"},{"Type":"sell","Price":"0.00003995","OrderTime":"2019-01-15 08:26:53","Quantity":"50.00000000"},{"Type":"sell","Price":"0.00003997","OrderTime":"2018-11-21 06:52:16","Quantity":"2501.87640731"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-11-21 22:39:54","Quantity":"250.00000000"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-11-24 06:43:28","Quantity":"203.00000000"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-11-29 18:31:15","Quantity":"300.00000000"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-12-08 01:21:39","Quantity":"10000.00000000"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-12-13 17:31:50","Quantity":"700.00000000"},{"Type":"sell","Price":"0.00003999","OrderTime":"2018-12-16 22:29:53","Quantity":"125.00000000"},{"Type":"sell","Price":"0.00004000","OrderTime":"2018-11-20 23:11:29","Quantity":"100.00000000"},{"Type":"sell","Price":"0.00004000","OrderTime":"2018-11-23 07:57:19","Quantity":"8713.33429268"},{"Type":"sell","Price":"0.00004000","OrderTime":"2019-01-27 19:00:43","Quantity":"1000.00000000"}],"BuyOrders":[{"Type":"buy","Price":"0.00003183","OrderTime":"2019-02-04 16:47:46","Quantity":"230.71347785"},{"Type":"buy","Price":"0.00003182","OrderTime":"2019-02-04 16:46:47","Quantity":"48.56097503"},{"Type":"buy","Price":"0.00003180","OrderTime":"2019-02-04 16:12:11","Quantity":"160.00000000"},{"Type":"buy","Price":"0.00003165","OrderTime":"2019-02-04 03:24:08","Quantity":"100.00000000"},{"Type":"buy","Price":"0.00003165","OrderTime":"2019-02-04 10:18:05","Quantity":"300.00000000"},{"Type":"buy","Price":"0.00003160","OrderTime":"2019-02-04 01:16:48","Quantity":"500.00000000"},{"Type":"buy","Price":"0.00003150","OrderTime":"2019-02-03 22:50:12","Quantity":"209.27422222"},{"Type":"buy","Price":"0.00003128","OrderTime":"2019-02-04 15:38:40","Quantity":"284.84654731"},{"Type":"buy","Price":"0.00003126","OrderTime":"2019-02-04 15:09:08","Quantity":"278.31094050"},{"Type":"buy","Price":"0.00003125","OrderTime":"2019-02-04 01:15:12","Quantity":"500.00000000"},{"Type":"buy","Price":"0.00003101","OrderTime":"2019-02-04 16:42:49","Quantity":"322.47662045"},{"Type":"buy","Price":"0.00003100","OrderTime":"2019-02-03 22:36:03","Quantity":"125.00000000"},{"Type":"buy","Price":"0.00003100","OrderTime":"2019-02-04 01:14:46","Quantity":"1000.00000000"},{"Type":"buy","Price":"0.00003096","OrderTime":"2019-02-03 20:34:18","Quantity":"288.00000000"},{"Type":"buy","Price":"0.00003090","OrderTime":"2019-02-03 19:32:46","Quantity":"90.00000000"},{"Type":"buy","Price":"0.00003080","OrderTime":"2019-02-03 13:05:29","Quantity":"65.00000000"},{"Type":"buy","Price":"0.00003080","OrderTime":"2019-02-04 13:10:46","Quantity":"380.00000000"},{"Type":"buy","Price":"0.00003071","OrderTime":"2019-02-03 02:02:46","Quantity":"83.21102572"},{"Type":"buy","Price":"0.00003051","OrderTime":"2019-02-03 00:38:51","Quantity":"143.33798755"},{"Type":"buy","Price":"0.00003050","OrderTime":"2019-02-03 00:12:25","Quantity":"100.00000000"},{"Type":"buy","Price":"0.00003040","OrderTime":"2019-02-03 00:03:48","Quantity":"90.00000000"},{"Type":"buy","Price":"0.00003030","OrderTime":"2019-02-03 00:01:19","Quantity":"100.00000000"},{"Type":"buy","Price":"0.00003020","OrderTime":"2019-02-02 23:58:32","Quantity":"194.76816071"},{"Type":"buy","Price":"0.00003015","OrderTime":"2019-02-02 22:46:00","Quantity":"340.00000000"},{"Type":"buy","Price":"0.00003011","OrderTime":"2019-02-04 11:47:26","Quantity":"230.50758834"},{"Type":"buy","Price":"0.00003010","OrderTime":"2019-02-02 13:43:38","Quantity":"1000.00000000"},{"Type":"buy","Price":"0.00002975","OrderTime":"2019-02-02 09:30:10","Quantity":"29.47899160"},{"Type":"buy","Price":"0.00002960","OrderTime":"2019-02-02 22:51:53","Quantity":"180.00000000"},{"Type":"buy","Price":"0.00002957","OrderTime":"2019-02-02 22:39:33","Quantity":"155.00000000"},{"Type":"buy","Price":"0.00002935","OrderTime":"2019-02-02 22:37:45","Quantity":"200.00000000"},{"Type":"buy","Price":"0.00002923","OrderTime":"2019-02-04 03:55:48","Quantity":"613.95077966"},{"Type":"buy","Price":"0.00002921","OrderTime":"2019-02-03 04:33:45","Quantity":"1027.04553235"},{"Type":"buy","Price":"0.00002920","OrderTime":"2019-02-02 22:30:44","Quantity":"1643.88561644"},{"Type":"buy","Price":"0.00002910","OrderTime":"2019-02-02 13:46:33","Quantity":"600.00000000"},{"Type":"buy","Price":"0.00002905","OrderTime":"2019-02-04 13:59:05","Quantity":"177.40543701"},{"Type":"buy","Price":"0.00002902","OrderTime":"2019-02-02 00:38:24","Quantity":"700.45309851"},{"Type":"buy","Price":"0.00002901","OrderTime":"2019-02-04 06:02:28","Quantity":"13683.81194088"},{"Type":"buy","Price":"0.00002900","OrderTime":"2019-01-14 07:53:54","Quantity":"10000.00000000"},{"Type":"buy","Price":"0.00002810","OrderTime":"2019-01-07 20:28:41","Quantity":"500.00000000"},{"Type":"buy","Price":"0.00002757","OrderTime":"2019-02-01 16:15:43","Quantity":"153.00000000"},{"Type":"buy","Price":"0.00002750","OrderTime":"2018-12-31 11:56:16","Quantity":"8.10128436"},{"Type":"buy","Price":"0.00002707","OrderTime":"2018-12-25 13:40:43","Quantity":"25.71681566"},{"Type":"buy","Price":"0.00002571","OrderTime":"2019-01-11 14:58:31","Quantity":"55.02546694"},{"Type":"buy","Price":"0.00002533","OrderTime":"2019-01-09 12:21:56","Quantity":"41.12180142"},{"Type":"buy","Price":"0.00002526","OrderTime":"2019-02-02 09:58:39","Quantity":"1187.64845606"},{"Type":"buy","Price":"0.00002525","OrderTime":"2018-12-11 10:47:35","Quantity":"2737.76718363"},{"Type":"buy","Price":"0.00002515","OrderTime":"2018-12-07 05:11:03","Quantity":"14.00000000"},{"Type":"buy","Price":"0.00002252","OrderTime":"2019-01-09 12:24:31","Quantity":"63.30144161"},{"Type":"buy","Price":"0.00002251","OrderTime":"2018-10-16 04:15:09","Quantity":"1500.00000000"},{"Type":"buy","Price":"0.00002251","OrderTime":"2018-11-22 17:39:26","Quantity":"37.00000000"}]}}
\ No newline at end of file
{"fv_bid":"0.05","fv_ask":"0.11","fm_bid":"0.088","fm_ask":"0.105","config":{"ASK_DEPTH_EUR":1000,"BID_DEPTH_EUR":1000,"ASK_OFFSET_EUR":0.01,"BID_OFFSET_EUR":0.01,"BID_MIN_EUR":0.05},"formulas":{"(1)fv_bid":"max ( BID_MIN_EUR&#44; int( ( bid_price - BID_OFFSET_EUR ) * 10 )\/10 )","(2)fm_bid":"free market bid price @ BID_DEPTH_EUR","(3)fm_ask":"free market ask price @ ASK_DEPTH_EUR","(4)fv_ask":"ask_price + ASK_OFFSET_EUR"}}
\ No newline at end of file
timestamp,fv_bid,fv_ask,fm_bid,fm_ask,bid_depth_eur,ask_depth_eur
1549279266,0.05,0.12,0.087,0.108,1000,1000
1549299566,0.05,0.11,0.088,0.105,1000,1000
Header set Access-Control-Allow-Origin "*"
<?php
ini_set('display_errors',1);
//define('COINEXCHANGE','../data/coinexchange.json');
//define('COINEXCHANGE_URL','https://www.coinexchange.io/api/v1/getmarketsummary?market_id=200');
define('COINEXCHANGE','../data/coinexchange.json');
define('COINEXCHANGE_URL','https://www.coinexchange.io/api/v1/getorderbook?market_id=200');
//https://www.coinexchange.io/api/v1/getorderbook?market_id=200
define('BITCOINAVERAGE','../data/bitcoinaverage.json');
define('BITCOINAVERAGE_URL','https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCEUR');
define('FREEVISION', '../data/freevision.json');
define('FREEVISION_HISTORY', '../data/freevision_history.csv');
define('ASK_DEPTH_EUR',1000);
define('BID_DEPTH_EUR',1000);
define('ASK_OFFSET_EUR',0.01);
define('BID_OFFSET_EUR',0.01);
define('BID_MIN_EUR',0.05);
define('REFRESH_TIME_SECONDS',3600);
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function update_data(){
$ARR=[COINEXCHANGE,BITCOINAVERAGE];
$ARR_URL=[COINEXCHANGE_URL,BITCOINAVERAGE_URL];
$ff=false;
foreach( $ARR as $key => $value ){
if( file_exists($value) ){
if( filemtime($value) + REFRESH_TIME_SECONDS > time() ){
$f=false;
} else {
$f=true;
}
} else {
$f=true;
}
if( $f ){
$json=curl($ARR_URL[$key]);
$fp=fopen($value,'w+');
fwrite($fp,$json);
fclose($fp);
$ff=true;
}
}
return get_data($ff);
}
function get_data($upd){
if( !$upd ){
// load data from folder
$ARR=[FREEVISION,FREEVISION_HISTORY];
$ARR_ID=['FREEVISION','HISTORY'];
$JS=[];
foreach( $ARR as $key => $value ){
$fp=fopen($value,'r');
$json=fread($fp,filesize($value));
fclose($fp);
if( preg_match('/\.csv/',$value ) ){
$JS[$ARR_ID[$key]]=$json;
} else {
$JS[$ARR_ID[$key]]=json_decode($json,true);
}
}
$H=preg_split('/
/',$JS['HISTORY']);
$JS['FREEVISION']['history']=$H;
return json_encode($JS['FREEVISION']);
}
// recalculate data
$ARR=[COINEXCHANGE,BITCOINAVERAGE,FREEVISION];
$ARR_ID=['BTCFAIR','BTCEUR','FREEVISION'];
$JS=[];
foreach( $ARR as $key => $value ){
$fp=fopen($value,'r');
$json=fread($fp,filesize($value));
fclose($fp);
$JS[$ARR_ID[$key]]=json_decode($json,true);
}
// calculate prices
$BTCEUR=$JS['BTCEUR'];
$BTCFAIR=$JS['BTCFAIR']['result'];
$ask_depth_btc=ASK_DEPTH_EUR/$BTCEUR['last'];
$bid_depth_btc=BID_DEPTH_EUR/$BTCEUR['last'];
$btceur=$BTCEUR['last'];
$c=0;
foreach($BTCFAIR['SellOrders'] as $order ){
if( $c < $ask_depth_btc ){
$c+=$order['Price'] * $order['Quantity'];
$lp=$order['Price'];
} else { break; }
}
$ask_price=$lp*$btceur;
$c=0;
foreach($BTCFAIR['BuyOrders'] as $order ){
if( $c < $bid_depth_btc ){
$c+=$order['Price'] * $order['Quantity'];
$lp=$order['Price'];
} else { break; }
}
$bid_price=$lp*$btceur;
$fv_bid_bid = max( BID_MIN_EUR, intVal(($bid_price - BID_OFFSET_EUR)*10)/10 );
$fv_bis_ask = max( BID_MIN_EUR, intVal(($ask_price - BID_OFFSET_EUR)*10)/10 );
$fv_ask = $ask_price+ASK_OFFSET_EUR;
// add hysteresis for freevision bid price
// if new calculation is lower than current price then ask side counts
// if new calculation is higher than current price then bid side counts
if( $fv_bid_ask < $JS['FREEVISION']['fv_bid'] ){
$fv_bid=$fv_bis_ask;
} elseif( $fv_bid_bid > $JS['FREEVISION']['fv_bid'] ) {
$fv_bid=$fv_bid_bid;
} else {
$fv_bid=$JS['FREEVISION']['fv_bid'];
}
$J=['fv_bid'=>number_format(round($fv_bid,2),2),
'fv_ask'=>number_format(round($fv_ask,2),2),
'fm_bid'=>number_format(round($bid_price,3),3),
'fm_ask'=>number_format(round($ask_price,3),3),
'config'=>[
'ASK_DEPTH_EUR'=>ASK_DEPTH_EUR,
'BID_DEPTH_EUR'=>BID_DEPTH_EUR,
'ASK_OFFSET_EUR'=>ASK_OFFSET_EUR,
'BID_OFFSET_EUR'=>BID_OFFSET_EUR,
'BID_MIN_EUR'=>BID_MIN_EUR
],
'formulas'=>[
'(1)fv_bid'=>'max ( BID_MIN_EUR&#44; int( ( bid_price - BID_OFFSET_EUR ) * 10 )/10 )',
'(2)fm_bid'=>'free market bid price @ BID_DEPTH_EUR',
'(3)fm_ask'=>'free market ask price @ ASK_DEPTH_EUR',
'(4)fv_ask'=>'ask_price + ASK_OFFSET_EUR'
]
];
$hist=time().','.$J['fv_bid'].','.$J['fv_ask'].','.$J['fm_bid'].','.$J['fm_ask'].','.BID_DEPTH_EUR.','.ASK_DEPTH_EUR.'
';
$fp=fopen(FREEVISION,'w+');
fwrite($fp,json_encode($J));
fclose($fp);
$fp=fopen(FREEVISION_HISTORY,'a+');
fwrite($fp,$hist);
fclose($fp);
/*
$fp=fopen(FREEVISION_HISTORY,'r');
$history=fread($fp,filesize(FREEVISION_HISTORY));
fclose($fp);
$H=preg_split('/
',$history);
*/
//$J['history']=$H;
//return json_encode($J);
return get_data(false);
}
echo update_data();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>FairCoin FreeVision Price Ticker
</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta name="robots" content="noindex, nofollow">
<link href="assets/bootstrap/bootstrap.min.css" rel="stylesheet">
<style>
.input-group-prepend, .input-group-prepend > span {
width:17em;
}
.finfo_config {
text-align:right;
background:lavender;
margin:0.5em;
padding:1em;
}
.finfo_formulas {
padding:1em;
background:lavender;
margin:0.5em;
}
.ticker {
margin:0.5em;
padding:1.5em;
background:steelblue;
}
#history > .row:first-child > .col {
font-weight:bold;
}
#history > .row > .col:nth-child(2),
#history > .row > .col:nth-child(3) {
color:blue;
}
</style>
</head>
<body>
<div class="container-fluid">
<h3>Faircoin FreeVision price ticker ( in testing )</h3>
<div class="row">
<div class="col-sm-4 ticker">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text prep">(1)FreeVision support price (bid)</span>
</div>
<div class="form-control" id="fv_bid">loading...</div>
<div class="input-group-append">
<span class="input-group-text">&euro;</span>
</div>
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">(2)FreeMarkt (bid)</span>
</div>
<div class="form-control" id="fm_bid">loading...</div>
<div class="input-group-append">
<span class="input-group-text">&euro;</span>
</div>
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">(3)FreeMarkt (ask)</span>
</div>
<div class="form-control" id="fm_ask">loading...</div>
<div class="input-group-append">
<span class="input-group-text">&euro;</span>
</div>
</div>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">(4)FreeVision support price (ask)</span>
</div>
<div class="form-control" id="fv_ask">loading...</div>
<div class="input-group-append">
<span class="input-group-text">&euro;</span>
</div>
</div>
</div>
<div class="col finfo_config">
<h4>API</h4>
<p><a href="data/freevision.json">JSON</a></p>
</div>
<div class="col finfo_config">
<h4>configuration parameters</h4>
<p id="conf"></p>
</div>
</div>
<div class="row">
<div class="col finfo_formulas">
<h4>calculation formulas</h4>
<p id="formulas"></p>
</div>
</div>
<div class="row">
<div class="col finfo_history">
<h4>history</h4>
<span id="history"></span>
</div>
</div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/bootstrap.bundle.min.js"></script>
<script src="assets/js/json.js"></script>
<script src="assets/js/ticker.js"></script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment