The Cancoin price script engine
The price of your buy or sell listing in the Cancoin Marketplace is powered by your listing's price script. Define your price by applying a simple margin to your favorite exchange, or write a multi-line lua script to take full control of your buy or sell price.
Price scripts
Cancoin price scripts are used to determine your listing's buy or sell price. The price engine will execute your script any time a market or currency variable in your script has changed, updating your listing's public buy or sell price at the same time. Cancoin provides an in-browser script editor that allows you to craft your scripts using live bitcoin market variables that are queried and updated from a number of sources, including Bitcoin Average and Open Exchange Rates. Cancoin price scripts are written in the Lua programming language, which when combined with the near infinite combination of market variables available, allow a high level of flexibility when determining your listing's price.
Lua is a simple programming language that contains few default keywords and has a basic grammar that is descriptive and easy to read & write as a beginner. Our goal is to allow anyone to create customized scripts, so an easy to grasp syntax was a priority. One of the greatest strengths of Lua is also it’s large range of implementations. The original implementation is written in C and is a favourite among video game developers, especially for advanced customizations and plugins. There are versions in Java and .Net to allow for embedding in those ecosystems.
Cancoin uses an implementation named Luerl which is written in Erlang and runs on the amazing BEAM virtual machine. This implementation allows us a number of benefits over other Lua implementations. These benefits include: Immutable lua environments, per-processor run queues, per-process reduction counting, and a preemptive scheduler with execution priority.
local margin = 1.04
my_price = USD * margin
return my_price
local margin = 1.04
my_price = btceUSD * margin
return my_price
local margin = 1.04
price = min(USD, USD_7d_avg)
myprice = price + margin
return price
local margin = 1.04
price = max(USD, USD_7d_avg)
myprice = price + margin
return price
Flat service fee
Create your price from a market variable with a flat service fee and margin included.
local margin = 1.04
local my_service_fee = 20
price = USD + my_service_fee + margin
return price
local margin = 1.04
local maxprice = 1700
if USD_24h_change_price > 25
then price = maxprice
else
price = USD + margin
end
return price
More information
Try it now:
cancoin.co/price_engine
Learn more about price engine operators and variables:
cancoin.co/price_engine/variables
Learn more about Lua:
Lua.org
Learn more about Luerl:
Luerl on Github
buying and selling bitcoins today!
Terms of Service   /   Privacy Policy