Problem - Trader For A Day - Restrictions - Tora Internship Test - April 2019 - INGInious
Problem - Trader For A Day - Restrictions - Tora Internship Test - April 2019 - INGInious
Problem - Trader For A Day - Restrictions - Tora Internship Test - April 2019 - INGInious
You probably heard about Bitcoin (BTC). Bitcoin is digital money that is not issued or controlled by
anyone. It is used to securely store and transfer any amount of value anywhere in the world. It is used to
buy goods and services, store wealth, or send value to anyone without the permission of a third party.
Besides cryptocurrency coins, like BTC, the crypto space also has tokens, security and utility based ones.
You can see a token as a right to do or claim something, from a vote, a role, to a discount or just a simple
value that represents something in a particular ecosystem, a company.
A utility token gives the owner the right to use the services or network of the company, yet no voting
rights or ownership.
A token is issued by a company in a nite number and o ered to investors in a ICO (Initial Coin O erings)
followed by public sale on crypto exchanges.
Caspian issued 400m CSPs which can be traded only with ETH
(Ethereum).
Trading concepts
Position
Suppose you buy 1 CSP. It means you have a position of 1 CSP (you own 1 CSP). When you sell that 1 CSP,
you liquidated your position, you have no more CSP.
Exposure
When having a position on any asset or currency (like CSP) you are exposed to the price uctuations of
that currency or asset. Having a high exposure means your risk of loss is higher in case of price volatility.
Each transaction done by a trader (eg. buy 1 CSP) must meet the trading regulations at exchange level.
Meaning that you can buy or sell taking into account the rules imposed by the exchange.
Brokerage fee
Crypto exchanges or brokers can impose some execution fees, so that they earn some money from the
amount you trade. For example an exchange can impose a 1 RON commision on each CSP bought.
Task
Let's see what is like to be a trader for a while. You can now buy or sell Caspian (CSP) but only using
Ethereum (ETH). Can you pro t from 2 exchange rates in your trading strategy ?
You are given an initial sum of money, a starting position on each of the 2 currencies and arrays of prices
of those currencies for multiple days. Your task is to design a trading strategy to maximize your amount
of money after those days (pro t) taking into account some restrictions.
Restrictions:
you can buy or sell CSP only using ETH but not RON.
you can trade (buy or sell) at most p% of your position in CSP in a day
each transaction in CSP has a fee (an exchange commision) attached to it.
You must have RON for paying the fees in order to make the transaction
Problem description
You start with a sum of money in RON - S (S >= 0), a position on ETH - PETH (PETH >= 0), a position on
CSP - PCSP (PCSP >= 0) and a restriction for position in CSP in a day - Tp% (on each day you can buy or
sell max Tp% * PCSP)
Given a number of days - D, prices on each day for ETH (ETH->RON) - CiETHRON and CSP (ETH -> CSP) -
CiETHCSP, the fees for buy FeeBUY and sell FeeSELL, the sum of money in RON available in day D
(Stotal) is calculated as the amount of money available in RON in day D (after commisions) plus the
money obtained by liquidating any open position on ETH and CSP in day D.
Example:
Given:
S=1000 // initial sum of money in RON
PETH=200 // initial position in ETH - amount of ETH held
PCSP=100 // initial position in CSP - amount of CSP held
D=10 // number of days
Tp%=30% // max % to sell/buy from your position of CSP in a day
FeeBUY=2 // fee in RON for buying CSP - 1 CSP bought = 2 RON paid besides th
FeeSELL=1 // fee in RON for selling CSP - 1 CSP sold = 1 RON paid besides th
CiETHRON=12 15 11 4 28 50 27 31 16 7 // price of ETH on each day (ETH
CiETHCSP=10 5 15 11 18 20 27 31 26 7 // price of CSP on each day (ETH->
steps:
day1: 30C -20E // buy 30CSP and then sell 20ETH
day2: -20c 30e // sell 20CSP and then buy 30ETH
day3: 0
day4: 0
day5: 0
day6: 0
day7: 0
day8: 0
day9: 0
day10: 0
File format
N=2
S=1000
PETH=200
PCSP=100
D=10
Tp%=30%
FeeBUY=2
FeeSELL=1
CiETHRON=12 15 11 4 28 50 27 31 16 7
CiETHCSP=10 5 15 11 18 20 27 31 26 7
S=1000
PETH=200
PCSP=100
D=10
Tp%=100%
FeeBUY=1
FeeSELL=1
CiETHRON=1 1 1 1 1 1 1 1 1 1
CiETHCSP=10 12 15 11 18 20 27 31 26 7
Submissions
Each trading strategy for corresponding scenarios must be submitted in a submission le (.out), with the
following format:
File format
each scenario should have D lines and scenarios are separated by new line
within a scenario, all transactions from a line i correspond to day i
each transaction from a line has a speci c format: <value>[E|C]
value >= 0 => buy, value < 0 => sell
E: ETH, using CiETHRON (ETH->RON) prices and PETH position
C: CSP, using CiETHCSP (ETH->CSP) prices and PCSP position
Example
N=2
S=1000
PETH=200
PCSP=100
D=10
Tp%=30%
FeeBUY=2
FeeSELL=1
CiETHRON=12 15 11 4 28 50 27 31 16 7
CiETHCSP=10 5 15 11 18 20 27 31 26 7
S=1000
PETH=200
PCSP=100
D=10
Tp%=100%
FeeBUY=1
FeeSELL=1
CiETHRON=1 1 1 1 1 1 1 1 1 1
CiETHCSP=10 12 15 11 18 20 27 31 26 7
30C -20E
-20c 30e
0
0
0
0
0
0
0
0
100C
0
0
0
0
0
0
0
0
0
Validation
In order for the submission to be accepted, it must follow the above format requirements. In case any
invalid actions are detected on any scenario, no score will be computed for that submission.
Scoring
The provided .out le is used by a simulator to apply the trading strategy given a scenario.
The score of a submission represents the points resulted from pro ts accross all scenarios from
input_v3.in le.
For each scenario the pro t represents a di erence between the sum of money from day D (Stotal) and
sum of initial money (both S and money obtained by liquidating the initial positions on ETH and CSP).
Source code
Results
Input le:
input_v3.in (csp_money_three/input_v3.in)
Output le:
Submit
Information
Author(s) Tora
Grade 0.0
Attempts 0
Submission limit 40 submissions
every 1 hour(s)
Submitting as
Cuc Gabriel Paul
Teams management
(/aggregation/inginious-internship-april-
2019)
For evaluation
Best submission
No submission
Submission history
No submission