Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Live Coding Assignment: Moving Average Crossover Signal Generator

Overview

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.


Part 1: Problem Understanding & Design (15-20 minutes)

Before writing any code, you must demonstrate your understanding of the problem to the interviewer.

Your Task

Explain the following concepts clearly to the interviewer:

  1. 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)?
  2. 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)?
  3. Output Requirements

    • What information should be included in the output parquet file?
    • What constitutes a "buy signal" row?

Deliverable

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.


Part 2: Implementation in Rust (90-100 minutes)

Input Data Format

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,1757782412

Requirements

Your Rust program should:

  1. Read the CSV file containing trading data
  2. Calculate moving averages on the price_in_sol field
    • Use parameters of your choice (e.g., 5-period short MA, 20-period long MA)
    • You should be able to explain your choice
  3. Detect buy signals when the short MA crosses above the long MA
  4. Output to Parquet file named crypto-signals.parquet with the following columns:
    • block_num (i64)
    • timestamp (i64) - from the block_time field
    • signal (String) - should contain "BUY_SIGNAL"

Technical Constraints

  • Use Rust (you may use any version)
  • You'll likely need these crates (or similar):
    • csv for reading CSV files
    • parquet or arrow for writing Parquet files
    • serde for deserialization
  • Only output rows where a buy signal is detected (no sell signals required)

Evaluation Criteria

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?

Tips

  • 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

Notes

⚠️ Acknowledgment: We understand this task is challenging, especially if you're newer to Rust. The language has a learning curve, particularly around borrowing and lifetimes. This is why we strongly encourage you to use AI assistants and search engines—this reflects real-world development practices. We're more interested in seeing your problem-solving approach than memorized syntax.


Submission

When complete, be prepared to:

  1. Run your program and show the generated crypto-signals.parquet file
  2. Explain your moving average parameters and why you chose them
  3. Walk through a few examples of detected buy signals
  4. Discuss any challenges you encountered and how you resolved them

Good luck!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors