1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
This project is to simulate an exchange in order to bakc test quant strategies.
Dependencies
python 3.5
pandas 0.23.0
spyder 3.2.8
plotly 2.7.0
Installation
pip install mini_exchange
Usage
# price: dataframe dt*ticker
# signal01: dataframe dt*ticker
# signal02: dataframe dt*ticker
dates=price.loc[start:end].index
tickers=price.columns
from mini_exchange import Mini_Exchange,Account,Log
MM=Mini_Exchange(price)
# create user01
acc01=Account(start_amount=1000)
log01=Log()
MM.register(user_name='user01',account=acc01,log=log01)
# create user02
acc02=Account(start_amount=1000)
log02=Log()
MM.register(user_name='user02',account=acc02,log=log02)
# trade
for dt in dates:
print('\rrun %d'%dt,end='\r')
MM.hold(dt)
for ticker in tickers:
#user01
if signal01.loc[dt,ticker]==1:
#open long
MM.long(ticker,amount=10,dt=dt,user='user01')
elif signal01.loc[dt,ticker]==-1:
#open short
MM.short(ticker,amount=10,dt=dt,user='user01')
elif signal01.loc[dt,ticker].isin((-2,2)):
#close
MM.close(dt,ticker, by='ticker',user='user01')
#user02
if signal02.loc[dt,ticker]==1:
#open long
MM.long(ticker,amount=10,dt=dt,user='user02')
elif signal02.loc[dt,ticker]==-1:
#open short
MM.short(ticker,amount=10,dt=dt,user='user02')
elif signal01.loc[dt,ticker].isin((-2,2)):
#close
MM.close(dt,ticker, by='ticker',user='user01')
MM.settle(dt)
# summary
# user01
print(acc01.annual_return(),acc01.sharpe_ratio(rf=0.03))
print(pos01.win_rate())
acc01.plot_history(by_pct=True)
pos01.plot_history_position()
history_position=pos01.pos
history_value=acc01.history_value
Metadata
Release files for Mini-Exchange 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Mini Exchange-0.0.8.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Mini_Exchange-0.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / Mini Exchange-0.0.8.tar.gz
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | Mini Exchange-0.0.8.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
545e1b96ba607ec5858840696c905057b521c4948d511974bef259559cb044d0
|
|
BLAKE2b-256 checksum How to use checksums |
b02d932b745f7a31d2f797fe141a796bb5db7d790936c8ca0b0348adbe5f1b41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5
|
Release files / Mini_Exchange-0.0.8-py3-none-any.whl
| Download URL | Mini_Exchange-0.0.8-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a2008041d19af9e2b2f9c50148d2edfb03e903f7c21ad18dc291bf59e5e7713
|
|
BLAKE2b-256 checksum How to use checksums |
a91a888973d820052a33b0bde6de5f86fe3f795d774ba972787a4f9acbcff173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5
|