Skip to main content
trade: Tools For Stock Trading Applications.
============================================
Copyright (c) 2015 Rafael da Silva Rocha
rocha.rafaelsilva@gmail.com
http://rochars.github.io/trade/
http://trade.readthedocs.org

[![Travis CI](https://api.travis-ci.org/rochars/trade.svg)](https://travis-ci.org/rochars/trade)
[![Coverage Status](https://coveralls.io/repos/rochars/trade/badge.svg?branch=master&service=github)](https://coveralls.io/github/rochars/trade?branch=master)
[![Docs](https://readthedocs.org/projects/trade/badge/)](http://trade.readthedocs.org/en/latest/)


What is it?
-----------
trade is a Python module that provides basic notions of assets, purchases,
sales, daytrades, cost deduction, rates, options, option exercises
and asset accumulation.

With the trade module you can:
* Identify daytrades in a group of operations
* Prorate commissions and other costs by groups of operations
* Apply rates on operations
* Calculate the average price of an asset after a series of operations
* Calculate profits or losses relative to an asset, considering all rates and costs involved on its operations


How do I install the trade module?
----------------------------------
The trade module can be installed with pip:

> pip install trade

To check if everything went OK, open the Python console and import the module:

```python
import trade
asset = trade.Asset(name='some asset')
print(asset.name)
#>> some asset
```


How can I use it?
-----------------
A basic example of the trade module in action:

```python
import trade

# create the asset that we are going to trade
asset = trade.Asset(name='Google Inc', symbol='GOOGL')

# create the accumulator to accumulate trades with the asset
accumulator = trade.Accumulator(asset)


print(accumulator.asset.name)
#>> Google Inc

print(accumulator.quantity)
#>> 0

print(accumulator.price)
#>> 0

print(accumulator.results)
#>> {'trades': 0}


# create a trade operation buying the asset
purchase = trade.Operation(
asset=asset,
quantity=10,
price=650.73,
date='2015-09-23'
)

# accumulate the trade
accumulator.accumulate_operation(purchase)


print(accumulator.quantity)
#>> 10

print(accumulator.price)
#>> 650.73

print(accumulator.results)
#>> {'trades': 0}


# create a new trade operation selling the asset
sale = trade.Operation(
asset=asset,
quantity=-5,
price=656.77,
date='2015-09-24'
)

# accumulate the new trade
accumulator.accumulate_operation(sale)


print(accumulator.quantity)
#>> 5

print(accumulator.price)
#>> 650.73

print(accumulator.results)
#>> {'daytrades': 0, 'trades': 30.199999999999818}
```

Operation objects may include rates and commissions that are considered by the
accumulator when it calculates results and average prices.

The Accumulator can also log the accumulated operations and their results.

Check the [documentation](http://trade.readthedocs.org) for all the available features.


What about compatibility?
-------------------------
The trade module is compatible with Python 2.7 and Python 3.x.


Version
-------
The current version is 0.1.0-alpha.


License
-------
Copyright (c) 2015 Rafael da Silva Rocha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trade-0.1.0.zip (26.2 kB view details)

Uploaded Source

File details

Details for the file trade-0.1.0.zip.

File metadata

  • Download URL: trade-0.1.0.zip
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for trade-0.1.0.zip
Algorithm Hash digest
SHA256 537ee955ab569bf20b7f28090e95e787acc52c5a54e92a0e30065e51d8e3e9f6
MD5 0dd633382e6c1b39eccba1642c101c1f
BLAKE2b-256 c1e8bf10d86ab89b2f0133f9e9a51d55980b1891abe1b3bceeac9dd4c98757b1

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

1 file

0.4.2

2 files

0.4.1

2 files

0.4

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

This release

0.1.0 This release

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page