In this assignment, you will build a Rust program that processes cryptocurrency trading data and generates buy signals based on a moving average crossover strategy.
Time Allocation: Up to 2 hours
Tools Allowed: You are encouraged to use AI coding assistants, search engines, and any online resources. This is a practical coding exercise, and we want to see how you approach problem-solving in a real-world scenario.
Before writing any code, you must demonstrate your understanding of the problem to the interviewer.
Explain the following concepts clearly to the interviewer:
-
Moving Average Crossover Strategy
- What is a simple moving average (SMA)?
- What does a "crossover" mean in trading?
- How do we generate a buy signal from a moving average crossover?
- What are the typical parameters (e.g., short-period MA and long-period MA)?
-
Data Processing Requirements
- What data points do we need from the CSV?
- How should we handle the sequential nature of the data?
- What edge cases might we encounter (e.g., insufficient data for MA calculation)?
-
Output Requirements
- What information should be included in the output parquet file?
- What constitutes a "buy signal" row?
Walk the interviewer through your approach:
- The logic for calculating moving averages
- When a buy signal is triggered
- The structure of your output data
You may only proceed to Part 2 after the interviewer confirms your understanding is correct.
You will be working with CSV data in this format:
block_time,transaction_signature,block_num,program_id,trade_type,wallet_address,token_address,is_buy,amount_in_sol,amount_in_token,change_in_sol,change_in_tokens,price_in_sol,virtual_sol_reserves,virtual_token_reserves,real_sol_reserves,real_token_reserves,fee_recipient,fee_basis_points,fee_amount,creator_address,creator_fee_basis_points,creator_fee_amount,ingested_at
1757782395,5xk1fk8eZFh7N6ydZc9YpaXx1QGEqbTDTFJX5WX7RhYucdxgiAvbG9NR4icwDhJgdasdYJh544GmQRZfv5s77BM,366586929,6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P,trade,Ab6VFq1eje9J8zNCqE9RdjYESMTPgz6cdir5gzWv2fxt,FCuk4XWLR6fAJFTcQoMrm3KeywSt2X6wK4Ufh4Xjpump,true,380000069,13421332211323,-380000069,13421332211323,0.0000000283,30380000069,1059578667788677,380000069,779678667788677,G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP,95,3610001,Ab6VFq1eje9J8zNCqE9RdjYESMTPgz6cdir5gzWv2fxt,30,1140001,1757782412Your Rust program should:
- Read the CSV file containing trading data
- Calculate moving averages on the
price_in_solfield- Use parameters of your choice (e.g., 5-period short MA, 20-period long MA)
- You should be able to explain your choice
- Detect buy signals when the short MA crosses above the long MA
- Output to Parquet file named
crypto-signals.parquetwith the following columns:block_num(i64)timestamp(i64) - from theblock_timefieldsignal(String) - should contain "BUY_SIGNAL"
- Use Rust (you may use any version)
- You'll likely need these crates (or similar):
csvfor reading CSV filesparquetorarrowfor writing Parquet filesserdefor deserialization
- Only output rows where a buy signal is detected (no sell signals required)
You will be evaluated on:
- Correctness: Does the program accurately detect moving average crossovers?
- Code quality: Is the code readable and reasonably organized?
- Problem-solving: How do you approach challenges and use available resources?
- Communication: Can you explain your decisions and trade-offs?
- Start simple: Get the CSV reading working first
- Test with a small subset of data initially
- Don't worry about perfect optimization—correctness matters more
- Ask questions if requirements are unclear
- Use
println!debugging liberally to verify your calculations
When complete, be prepared to:
- Run your program and show the generated
crypto-signals.parquetfile - Explain your moving average parameters and why you chose them
- Walk through a few examples of detected buy signals
- Discuss any challenges you encountered and how you resolved them
Good luck!