Skip to main content

trading api

Project description

Welcome to etonger !

This is a repo for the etonger trading engine under the Mac OSX system.

Author

etonger ©RobinShare, Released under the GPL-3.0 License.

What's etonger support for?

e海通财PC端Mac版.

Details:

1、e海通财PC端Mac3.08版,支持Mac10.12以上版本。

2、支持科创板交易和新股申购业务。

3、支持普通交易、融资融券、贵金属三种交易类型。

5、支持多个基金品种交易,如场内基金、分级基金、ETF申赎、场外开放基金等业务功能。

6、支持新股一键申购,打新从此更方便。

7、增加沪深全景图,创业板注册制,全面支持IPv6。

8、支持在线客户服务,24小时在线为您解答。

Repo structure

etonger/
    ├── LICENSE
    ├── pyproject.toml
    ├── README.md
    ├── setup.py  
    ├── src/
    │   └── etonger/
    │        ├── __init__.py
    │        ├── ascmd.py
    │        ├── ehelper.py             
    │        └── etonger.py
    └── tests/

tree ~/.config/etonger
    ~/.config/etonger
    └── config.xml

Installation guide

  1. Requirements

    • python >= 3.9.4
  2. Dependencies

    brew install cliclick
    cliclick -V             # cliclick 4.0.1, 2018-04-10
    which cliclick          # /usr/local/bin/cliclick
    
    pip install pandas==1.2.4
    
  3. Installation

    • Building etonger from pip

      pip3 install -i https://test.pypi.org/simple/ etonger==1.1.8
      
    • Building etonger from source

      git clone git@github.com:RobinShare/etonger.git ~/etonger; cd ~/etonger; python setup.py install; rm -rf ~/etonger
      
  4. Configuration

    mkdir -p ~/.config/etonger
    
    echo """
    <etonger>
        <trading>
            <userid>77777777777</userid>
            <password>123456</password>
            <broker_code>PAZQ</broker_code>
            <broker_account>66666666</broker_account>
            <broker_password>123456</broker_password>
            <bank_name>华夏银行</bank_name>
            <bank_account>666666666666666666</bank_account>
            <bank_password>123456</bank_password>
        </trading>
        <mail>
            <mail_host>smtp.163.com</mail_host>
            <mail_sender>mailAddress@163.com</mail_sender>
            <mail_license>SNRRQOKFKEUNNSFT</mail_license>
            <mail_receivers>mailAddress@163.com</mail_receivers>
        </mail>
    </etonger>
    """ > ~/.config/etonger/config.xml
    

How to use

etongerDemo.py

# -*- coding: utf-8 -*-
#After you have run "pip3 install -i https://test.pypi.org/simple/ etonger==1.1.8"

from etonger import etonger 
import time

if __name__ == "__main__":
    pass
    # --- Service
    # -----------------------------------------
    service = etonger.Service()

    status = service.isClientLoggedIn()
    print(status)
    time.sleep(1)

    status = service.loginClient()
    print(status)
    time.sleep(1)

    status = service.isClientLoggedIn()
    print(status)
    time.sleep(1)

    status = service.logoutClient()
    print(status)
    time.sleep(1)

    status = service.isClientLoggedIn()
    print(status)
    time.sleep(1)

    status = service.reLoginClient()
    print(status)
    time.sleep(1)

    status, entrustDf = service.getEntrustInfo()
    print("status:", status, "entrustDf:", entrustDf)

    time.sleep(5)
    status = service.lockClient()
    print("status:",status)


    #---暂时不知道锁屏后怎么解锁操作,待定
    # service.unlockClient()



    # --- Etonger
    # -----------------------------------------
    tonger = etonger.Etonger()
    tonger.keepInformed = True

    status = tonger.isBrokerLoggedIn()
    print(status)

    status = tonger.loginBroker()
    print(status)

    status = tonger.isBrokerLoggedIn()
    print(status)

    accountInfo = tonger.getAccountInfo()
    print("accountInfo:",accountInfo)

    status, entrustDf = tonger.getEntrustMentInfo()
    print("status:",status, "entrustDf:", entrustDf)

    status, entrustNo = tonger.sellAStock(stock_code='600336', price=7.45, amount=100, mode=0)
    print("status:", status, "entrustNo:", entrustNo)

    status, entrustNo = tonger.sellAStock(stock_code='300059', price=32.29, amount=100, mode=5)
    print("status:", status, "entrustNo:", entrustNo)

    statusList, entrustNoDict = tonger.sellAllStocks(stock_codeList=['600336','300059'], priceList=[7.28, 32.88], amountList=[100,500], mode=0)
    print("statusList:", statusList, "entrustNoDict:", entrustNoDict)

    status, entrustNo = tonger.buyAStock(stock_code='300059', price=29.29, amount=100, mode=0)
    print("status:", status, "entrustNo:", entrustNo)

    status, entrustNo = tonger.buyAStock(stock_code='600336', price=7.29, amount=100, mode=2)
    print("status:", status, "entrustNo:", entrustNo)

    statusList, entrustNoDict = tonger.buyAllStocks(stock_codeList=['600336','300059'], priceList=[6.59, 28.29], amountList=[100,100], mode=0)
    print("statusList:", statusList, "entrustNoDict:", entrustNoDict)

    positionDataFrame = tonger.checkPosition()
    print("positionDataFrame:", positionDataFrame)

    time.sleep(15.0)
    status = tonger.cancelAllSellStocks()
    print(status)

    status = tonger.cancelAllStocks()
    print(status)

    status = tonger.cancelAllBuyStocks()
    print(status)

    status = tonger.oneKeyIPO()
    print(status)


For more information

  • Hint:
    • If you want to use the email notification module, you need to open a 163 email account.
    • Be Careful【手动要求】:
      • 客户端手动提前设置:双向委托[F6]---->>>>委托(R),勾选☑️可撤委托,同时向右拖动该窗口,让委托信息中全部列名可见。【注意:版式切换不要变更,使用原来的版式<上>】

Project details


Download files

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

Source Distribution

etonger-1.1.8.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

etonger-1.1.8-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file etonger-1.1.8.tar.gz.

File metadata

  • Download URL: etonger-1.1.8.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for etonger-1.1.8.tar.gz
Algorithm Hash digest
SHA256 2d346ba6e4e77de2579872ce8c4f37e60e17158bbabdfa1ed44b18da4f27a419
MD5 489fbe95e1e27fec5808a8101d1e8950
BLAKE2b-256 48696ddb16213b758b723181056f77207dd60ae9582f555db3e56a9256d19c5a

See more details on using hashes here.

File details

Details for the file etonger-1.1.8-py3-none-any.whl.

File metadata

  • Download URL: etonger-1.1.8-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for etonger-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 cb3fdba88b51e05b424e61de54fb4422591ec21dbc8e036da28a0a487cd5d15f
MD5 2b2601b322e39e20dfa49c7af65e4f1d
BLAKE2b-256 8368c462977c062427b8439623abb1de3c0d3b5836ff59dcafe63b49440c7a33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page