Giter VIP home page Giter VIP logo

m1lib's Introduction

M1 Finance Python 3 + Selenium Wrapper

There is no public API available for M1 Finance, which presents an opportunity...

pid = the string at the end of any Pie's URL, /d/invest/portfolio/Q1BTOYwODE5MCw2jVRTjQyODE1LDMDk5MTc%3D

Dependencies:

You probably already have:

  • Python 3+
  • Python Package: re

You will need:

Installation:

  1. Download ZIP or GIT with git clone https://github.com/etz/m1lib.git
  2. In terminal, cd /path/to/m1lib
  3. Modify the py file
  4. python3 main.py

Usage:

from m1lib import *
from config import *

Basic / Authentication

login(username, password) - Logs into the M1Finance Account using Chromedriver

selectAccount(accountType) - Selects the account to make changes in

closeSession() - Closes the associated account

Trading

Buying

orderPie(amount, pid) - Orders amount of pie based on string pid

orderPV(amount, accountType) - Orders $amount of the M1 Portfolio labeled accountType

getPID(accountType) - Returns the Pie ID of the accountType from the config file.

cancelOrder(pid) - Cancels the order associated with Pie ID (use getPID for PVs)

Returns

checkReturnsPV(accountType, "week") - Returns the gains/losses as a percentage(float) against a portfolio

checkReturnsPie(pid, "week") - Returns the gains/losses as a percentage(float) against a pie

Actions

rebalancePie(pid) - Sets a specific Pie ID for rebalance

rebalancePV(accountType) - Sets accountType for rebalance

initiateDeposit(amount, accountType, year='') - Initiate a deposit for a selected account. If IRA, set a third variable year=2019

initiateWithdraw(amount, accountType) - Initiate a withdraw for a selected account.

Search & Options

tickerSearch(mk_min='',mk_max='',pe_min='',pe_max='',div_min='',div_max='',sector='',industry='') - searches M1 for all stocks within set parameters.

tickerSearch(aum_min='',aum_max='',exp_min='',exp_max='',div_min='',div_max='',sector='',industry='') - searches M1 for all funds within set parameters.

searchTicker(ticker) - Returns [float(price), float(div_yield), str(mkcap), float(pe_ratio)] of string ticker

getCurrentMarketData() - Returns the [day] % difference in the SPY, DIA, and QQQ tickers similar to searchTicker

changeAutoInvest(accountType, option='', amount='') - options=set/all/off, use amount if options=set

Credits

Developed by Ethan Nadzieja.

TODO

This project is not designed to re-invent the wheel, therefore the library functionality will be limited in trading features.

  • Cash Only support
  • "Borrow" balance support
  • Misc. features
  • Cancel PV Orders

m1lib's People

Contributors

etz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mariahakinbi

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.