Git Product home page Git Product logo

htn-challenge-2017's Introduction

htn-challenge-2017

At Wealthsimple, portfolios have a specified distribution of asset holdings called a target_allocation. This allocation is based on the total value of the asset. For example, a 50/50 allocation between asset A and asset B means the total value of all the asset A you hold is equal to the total value of all the asset B you hold.

When the market price of certain assets change, the account deviates from its target_allocation. When this happens, we can restore the specified balance of assets by buying and selling stocks so that the desired ratio of assets is recovered.

Challenge

Given a portfolio's target_allocation (ratio of assets), portfolio_holdings (number of each asset), and asset_prices (the cost per unit of the asset), generate a series of trades to ensure the portfolio is balanced according to the target_allocation.

BONUS: We don't want to increase operating costs by doing penny trades. If an asset is within 0.5% of its target allocation, do not trade that asset.

BONUS BONUS: Although Wealthsimple can trade fractions of an asset, not all brokerages can. Apply this restriction to your code and get as close to the target allocation as possible.

Specifications

You must create a script in Python3, Ruby, or Javascript. This script should read from a file containing test data like the test cases provided, and the name of the file should be configurable.

The output of the script should be a list of trades generated, formatted like the following example:

We placed 3 trades:
1. Bought 120 units of XIC
2. Sold 45 units of ZFM
3. Sold 20 units of VUS

Submission

Please fork this repository and make a pull request. It's highly recommended you do this before you start, since you're very likely to run out of time if you attempt to do this at the end.

Do include instructions in your pull request, such as how to configure the test filename and how to run your script.

htn-challenge-2017's People

Contributors

peicodes avatar

Watchers

James Cloos avatar Jerry Li avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.