📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

Belvedere Trading 24ng OA

全局:

2024(7-9月) 码农类General 硕士 全职@belvederetrading - 网上海投 - 在线笔试  | 😐 Neutral 😐 Average | Other | 应届毕业生
Belvedere TrainingSoftware Engineer - Entry Level 2024 Chicago

新人求加米 看面经~🙏🙏🙏

这家准备的时候在地里找不到太多信息和oa,尤其是找不到24的。于是就用地里找的往年的题(斐波那契,four corners, 一个算数的trading题,manufacturing problem,naive hedging algorithm这五道题)练的。但今年换了新题

平台: HireVue 不太好用,而且test cases给的很少。具体样子看下图。不要开cam
三道题,每交一题看下一题
Trade Aggregator 30min
Concert Ticket Exchange 60min
Opportunistic Stock Trading 60min

我感觉主要是考察oop,数据结构和算法都不是很难,但是题目描述比较复杂,还涉及一些trading的知识。
题目已经给了代码框架(一些func和struct)只用写几个函数之类的
第一题text有的乱码了可以结合最底下图一起看

如有帮助请加点米吧谢谢!
--------------------------------------------------------------------------------------------------------------
1Trade Aggregator
When a trader buys or sells an asset, that trade is said to have a certain amount of "edge" defined as the difference between the trade price and a theoretical value. Theoretical value is what the Trader or Firm thinks the asset is worth, and can change throughout the day.
Edge_{buy} = TheoreticalValue - TradePriceEdge
?buy
?? =TheoreticalValue?TradePrice Edge_{sell} = TradePrice - TheoreticalValueEdge
?sell
?? =TradePrice?TheoreticalValue
Traders typically want to execute trades that have positive edge, that is buying an asset for lower than the theoretical value, or selling an asset for higher than the theoretical value.
For example: TradePrice = 95, TheoreticalValue = 100, Edge = 100-95 = 5
As a Firm, we want to track which traders are making the best decisions, so we calculate a score for each trade.
Score = SignOfEdge(Edge^2 * {|Quantity|} )Score=SignOfEdge(Edge
?2
?? ?∣Quantity∣)
Notice that negative edge will result in a negative score, indicating a bad trade.
Task
Given a series of trades, print the trader with the highest cumulative score after each trade.
Additional Details
A "Buy" trade will have positive quantity, and "Sell" trades will be denoted by negative (-) quantity.
Theoretical Values can be updated periodically. Your solution should use the most recent theoretical value when calculating edge. If an asset does not have an available theoretical value at the time of trade, assume Edge = 0 and save the trade price as the theoretical value. Theo Updates are not retroactive, so any existing trade for that asset should NOT be updated
Trades may happen with negative edge. They are valid and should be included in a traders cumulative score.
If more than one trader has the highest cumulative score, use lexicographical ordering of TraderName to break the tie.
input:A number trade lines in the following format:
Trade <TraderName> <Asset> <Quantity> <Price>
Interlaced with 1 or more theo update lines in the following format:
TheoUpdate <Asset> <Value>
Example:
TheoUpdate 1 100
Trade Alice 1 1 95
Trade Bob 1 1 94
Trade Alice 1 -1 107
output:
A line of output for each trade in the input, in the format
<TraderName> <Score>
Example:
Alice 25
Bob 36
Alice 74
----------------------------------------------------------------------------------------------------------------------------
下载测试 1 输入
TheoUpdate 1 100
Trade Alice 1 1 95
Trade Bob 1 1 94
Trade Alice 1 -1 107
预期输出
Alice 25.00
Bob 36.00
Alice 74.00
下载测试 2 输入
TheoUpdate 1 100
Trade Alice 1 -2 101
Trade Bob 1 -2 99
预期输出
Alice 2.00
Alice 2.00
下载测试 3 输入
TheoUpdate 1 100
Trade Alice 1 400 99
Trade Bob 1 5 90
预期输出
Alice 400.00
Bob 500.00
下载测试 4 输入
TheoUpdate 1 100
TheoUpdate 2 200
Trade Alice 1 1 98
Trade Bob 2 1 199
预期输出
Alice 4.00
Alice 4.00
--------------------------------------------------------------------------------------------------------------------------------
2  Concert Ticket Exchange
Concert tickets can be hard to come by, especially when going through the resale market. We would like to build our own concert ticket exchange system so that we can view available tickets in real-time. This system will listen to incoming ticket orders for a new concert venue, BT Arena. We'd like to build a system that listens to concert ticket orders and provides fans with this market information in the form of a price ladder.
Concert ticket orders arrive as a stream of events that can either add an order to our market data book or delete an order from our book. We also want to be able to delete all orders at given price level.
Add orders come with the following information:
Action - ADD
OrderId - unique identifier for order
Artist - concert performer, such as "TaylorSwift" or "Drake"
Price - price for the order
Quantity - positive quantity is a buy order and negative quantity is a sell order
Delete orders come with the following information:
Action - DEL
Artist - concert performer, such as "TaylorSwift" or "Drake"
OrderId - Unique identifier for the order to be deleted
Delete price levels come with the following information:
Action - DEL_PRICE
Artist - concert performer, such as "TaylorSwift" or "Drake"
Price - price level to be deleted
We'd like to keep track of these events so that fans can request a market view in the form of a price ladder. A price ladder is made up of n price levels for buy orders and sell orders. A price level consists of the Price, BuyQuantity, and SellQuantity. A price level will either have a non-zero BuyQuantity or SellQuantity, but not both. For buy orders, the best price is the highest price because that is the price a ticket holder would sell at. Conversely, the best price for sell orders is the lowest price. The streamed events will guarantee at least n price levels for both buys and sells.
input:
Repeated number of order operations in the following format:
<ADD> <OrderId> <Artist> <Price> <Quantity>
<DEL> <OrderId> <Artist>
<DEL_PRICE> <Artist> <Price>
We can get orders for different artists in the same stream of operations. The last line of input will the artist and number of price levels that we would like to view in our ladder for both buy and sell orders.
<Artist> <Num
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
riceLadder.GetPriceLevels(artist, numberOfPriceLevels);
    }
  }
}
第三题
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <exception>
#include <sstream>
#include <iomanip>


struct Bundle
{
std::string name;
double price;
int numComponents;
std::vector<std::pair<int, std::string>> components;
};

struct Stock
{
std::string name;
double price;
};

class MarketWatchPortfolio
{
private:
std::vector<Bundle> _bundles;
std::unordered_map<std::string, Stock> _stocks;

public:
MarketWatchPortfolio(std::vector<Bundle> const& bundles, std::unordered_map<std::string, Stock> const& stocks)
  : _bundles(bundles), _stocks(stocks)
{}

void ExecuteTrades()
{
  // TODO(candidate): implement logic here
}


private:
void PrintTrade(std::string const& symbol, std::string const& bundleOrIndividualStock, double cost)
{
  std::cout << std::setprecision(2) << std::fixed;
  std::cout << symbol << " E " << bundleOrIndividualStock << " " << cost << std::endl;
  return;
}

void PrintNoTrade(std::string const& symbol)
{
  std::cout << symbol << " P" << std::endl;
  return;
}
};

class InputData
{
public:
int numBundles;
int numStocks;

MarketWatchPortfolio LoadInput()
{
  std::vector<Bundle> bundles;
  std::unordered_map<std::string, Stock> stocks;
  std::string line;
  int numStocks = -1;
  int numBundles = -1;
  while (std::getline(std::cin, line))
  {
   if (line.empty())
   {
    break;
   }
   std::stringstream ss;
   ss << line;
   if (numStocks == -1 && numBundles == -1)
   {
    ss >> numBundles >> numStocks;
    continue;
   }
   if (numBundles > 0)
   {
    Bundle bundle{};
    auto const& components = SplitString(line, " ");
    bundle.name = components[0];
    bundle.price = std::stod(components[1]);
    bundle.numComponents = std::stoi(components[2]);
    for (std::size_t i = 3; i < components.size() - 1; i = i + 2)
    {
     auto const& c = std::make_pair(std::stoi(components[i + 1]), components[i]);
     bundle.components.push_back(c);

    }
    bundles.push_back(bundle);
    numBundles--;
    continue;
   }
   Stock stock;
   ss >> stock.name >> stock.price;
   stocks.emplace(stock.name, stock);
  }

  return MarketWatchPortfolio{ bundles, stocks };
}

private:
std::vector<std::string> SplitString(const std::string& str, const std::string& delimiter)
{
  std::vector<std::string> strs;
  size_t startPos = 0;
  size_t endPos = 0;
  while ((endPos = str.find(delimiter, startPos)) != std::string::npos)
  {
   strs.emplace_back(str.substr(startPos, endPos - startPos));
   startPos = endPos + 1;
  }
  strs.emplace_back(str.substr(startPos));
  return strs;
}
};

int main()
{
InputData inputData;
auto portfolio = inputData.LoadInput();
portfolio.ExecuteTrades();
}


本帖子中包含更多资源

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x

评分

参与人数 11大米 +35 收起 理由
Lothric_z + 1 很有用的信息!
Lucas顾 + 1 点个赞
WaterFriend + 1 很有用的信息!
bryanjhy + 25 给你点个赞!
Daixzzzzz + 1 给你点个赞!

查看全部评分


上一篇:citadel sde ng oa 2023-2024 新人求加米
下一篇:imc sde ng oa 2023-2024 求加米
🔗
zhuyuqiang52 2023-8-18 02:36:20 | 只看该作者
全局:
太牛啦!不知道trader的oa有多少是类似的
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XVUG8  2023-8-23 14:58:15
楼主有收到后续吗
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XVUG8  2023-8-23 14:59:00
楼主有收到后续面试吗
回复

使用道具 举报

🔗
 楼主| 橙色无尽狮子 2023-8-27 20:55:54 | 只看该作者
全局:

暂时还没收到消息
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表