DCA Martingale strategy calculator.
Project description
dcamarcal
DCA Martingale strategy calculator.
Overview
dcamarcal is a Python library designed to support the analysis of martingale-based DCA strategies in the cryptocurrency market by calculating order tables.
Features
The library is developed with the following key features in mind:
- No dependencies: Does not use any external library.
- High precision: Uses
decimalmodule enhance precision. - Bidirectional: Support both long and short martingale-based DCA strategies.
Examples
Basic usage:
from dcamarcal.calculator import DCAMartingale, Direction, round_order_list, print_tabular
dca = DCAMartingale.from_float(
direction=Direction.long, # or Direction.short
base_order_size=20, # initial order size
order_size=20, # starting size for subsequent orders
max_orders=8, # max number of orders
price_deviation=1.2, # deviation required to trigger the next order
target_profit=1.2, # profit required to close the position
order_scale=1.2, # scaling factor for order deviation
volume_scale=1.5, # scaling factor for order size
minimum_trade_decimals=5, # minimum number of decimals allowed in the market
)
result = dca.calculate_table(1) # starting price
result = round_order_list(result) # round to default 8 decimals
print_tabular(result) # display the table
Note: The
minimum_trade_decimalsparameter should match the requirements of your chosen exchange.
That generates the following order table:
| Order | Deviation | Size | Volume | Price | Average Price | Required Price | Required Change | Total Size | Total Volume |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.000000000 | 20.000000000 | 20.000000000 | 1.00000000 | 1.00000000000 | 1.012000000000 | 1.2000000000000 | 20.0000000000 | 20.0000000000 |
| 1 | 1.200000000 | 20.242914980 | 20.000000000 | 0.98800000 | 0.99396378000 | 1.005800000000 | 1.8016194300000 | 40.2429149800 | 40.0000000000 |
| 2 | 2.640000000 | 30.813475760 | 30.000000000 | 0.97360000 | 0.98513307000 | 0.996900000000 | 2.3931799500000 | 71.0563907400 | 70.0000000000 |
| 3 | 4.368000000 | 47.055378950 | 45.000000000 | 0.95632000 | 0.97365403000 | 0.985300000000 | 3.0303664000000 | 118.111769690 | 115.000000000 |
| 4 | 6.441600000 | 72.147450150 | 67.500000000 | 0.93558400 | 0.95921764000 | 0.970700000000 | 3.7533775700000 | 190.259219840 | 182.500000000 |
| 5 | 8.929920000 | 111.17811690 | 101.25000000 | 0.91070080 | 0.94132334000 | 0.952600000000 | 4.6007646000000 | 301.437336740 | 283.750000000 |
| 6 | 11.91590400 | 172.42045602 | 151.87500000 | 0.88084096 | 0.91931589000 | 0.930300000000 | 5.6149795800000 | 473.857792750 | 435.625000000 |
| 7 | 15.49908480 | 269.59767177 | 227.81250000 | 0.84500915 | 0.89237020000 | 0.903000000000 | 6.8627479200000 | 743.455464520 | 663.437500000 |
| 8 | 19.79890176 | 426.07739482 | 341.71875000 | 0.80201098 | 0.85945106000 | 0.869700000000 | 8.4399115600000 | 1169.53285934 | 1005.15625000 |
Current issues
- The
print_tabularfunction currently pads numbers with additional zeroes to align table columns, which might lead to visual inconsistency in decimal places.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dcamarcal-0.0.1.tar.gz.
File metadata
- Download URL: dcamarcal-0.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1281392837f05eb7a46d08b6f11a95e86ab9cde6de572fa2a8f0f5f61bc50bfd
|
|
| MD5 |
1d7fa48888283bf0827f86df14c4551f
|
|
| BLAKE2b-256 |
7698c98644bca722d540a17e28b0e6f82e5520e21860d97432cd3a6e10efb6ae
|
File details
Details for the file dcamarcal-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dcamarcal-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d683155f0857b7da56eaa6296871218d3e241c60a9ec35b08eec733fa488a83
|
|
| MD5 |
34eb0097f23147470c24c5af464cfd86
|
|
| BLAKE2b-256 |
68adc320e844b7184f54477c82611c70ace0396ed8fe88b0b5ea17dd3981a63a
|