系統windows 7 x86
python 3.8.5 x86
最近用python串接元大oneapi遇到下面的問題
Traceback (most recent call last):
File "C:\Users\trevor\Desktop\HSUNJEN\YuantaOneOrder.py", line 9, in <module>
objYuantaOneAPI.Login(System.String('98875005091'), System.String('1234'))
System.NullReferenceException: 並未將物件參考設定為物件的執行個體。
於 YuantaOneAPI.YuantaOneAPITrader.Login(String Account, String Password)
原始碼:
import clr
import System
path = "c://Yuanta//ONE//YuantaOneAPI.dll"
clr.AddReference(path)
from YuantaOneAPI import YuantaOneAPITrader
objYuantaOneAPI = YuantaOneAPITrader()
objYuantaOneAPI.Open()
objYuantaOneAPI.Login(System.String('98875005091'), System.String('1234'))
HELP資訊:
Help on YuantaOneAPITrader in module YuantaOneAPI object:
class YuantaOneAPITrader(System.Object)
| Void .ctor()
|
| Method resolution order:
| YuantaOneAPITrader
| System.Object
| builtins.object
|
| Methods defined here:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __repr__(self, /)
| Return repr(self).
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __str__(self, /)
| Return str(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from CLR.CLR Metatype
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| Close
| Void Close()
|
| Dispose
| Void Dispose()
|
| Finalize
| Void Finalize()
|
| GetQuoteList
| Boolean GetQuoteList()
|
| GetQuoteListDetail
| Boolean GetQuoteListDetail()
|
| LogOut
| Boolean LogOut()
|
| Login
| Boolean Login(System.String, System.String)
|
| OnResponse
|
| Open
| Void Open(YuantaOneAPI.enumEnvironmentMode)
|
| Overloads
|
| RQ
| Boolean RQ(System.String, YuantaOneAPI.YuantaDataHelper)
|
| SendFutureOrder
| Boolean SendFutureOrder(System.String, System.Collections.Generic.List`1[YuantaOneAPI.FutureOrder], YuantaOneAPI.enumLangType)
|
| SendOVFutureOrder
| Boolean SendOVFutureOrder(System.String, System.Collections.Generic.List`1[YuantaOneAPI.OVFutureOrder], YuantaOneAPI.enumLangType)
|
| SendStockOrder
| Boolean SendStockOrder(System.String, System.Collections.Generic.List`1[YuantaOneAPI.StockOrder], YuantaOneAPI.enumLangType)
|
| SetLogType
| Void SetLogType(YuantaOneAPI.enumLogType)
|
| ShowPostA
| Void ShowPostA(Boolean)
|
| SubscribeFiveTickA
| Boolean SubscribeFiveTickA(System.Collections.Generic.List`1[YuantaOneAPI.FiveTickA], YuantaOneAPI.enumLangType)
|
| SubscribeFiveTickB
| Boolean SubscribeFiveTickB(System.Collections.Generic.List`1[YuantaOneAPI.FiveTickB], YuantaOneAPI.enumLangType)
|
| SubscribeQuote
| Boolean SubscribeQuote(System.String, YuantaOneAPI.YuantaDataHelper)
|
| SubscribeStockTick
| Boolean SubscribeStockTick(System.Collections.Generic.List`1[YuantaOneAPI.StockTick], YuantaOneAPI.enumLangType)
|
| SubscribeWatchlist
| Boolean SubscribeWatchlist(System.Collections.Generic.List`1[YuantaOneAPI.Watchlist], YuantaOneAPI.enumLangType)
|
| SubscribeWatchlistAll
| Boolean SubscribeWatchlistAll(System.Collections.Generic.List`1[YuantaOneAPI.WatchlistAll], YuantaOneAPI.enumLangType)
|
| UnsubscribeFivetickA
| Boolean UnsubscribeFivetickA(System.Collections.Generic.List`1[YuantaOneAPI.FiveTickA], YuantaOneAPI.enumLangType)
|
| UnsubscribeFivetickB
| Boolean UnsubscribeFivetickB(System.Collections.Generic.List`1[YuantaOneAPI.FiveTickB], YuantaOneAPI.enumLangType)
|
| UnsubscribeQuote
| Boolean UnsubscribeQuote(System.String, YuantaOneAPI.YuantaDataHelper)
|
| UnsubscribeStocktick
| Boolean UnsubscribeStocktick(System.Collections.Generic.List`1[YuantaOneAPI.StockTick], YuantaOneAPI.enumLangType)
|
| UnsubscribeWatchlist
| Boolean UnsubscribeWatchlist(System.Collections.Generic.List`1[YuantaOneAPI.Watchlist], YuantaOneAPI.enumLangType)
|
| UnsubscribeWatchlistAll
| Boolean UnsubscribeWatchlistAll(System.Collections.Generic.List`1[YuantaOneAPI.WatchlistAll], YuantaOneAPI.enumLangType)
|
| __overloads__
|
| add_OnResponse
| Void add_OnResponse(YuantaOneAPI.OnResponseEventHandler)
|
| remove_OnResponse
| Void remove_OnResponse(YuantaOneAPI.OnResponseEventHandler)
|
| ----------------------------------------------------------------------
| Data descriptors inherited from System.Object:
|
| Equals
| Boolean Equals(System.Object)
| Boolean Equals(System.Object, System.Object)
|
| GetHashCode
| Int32 GetHashCode()
|
| GetType
| System.Type GetType()
|
| MemberwiseClone
| System.Object MemberwiseClone()
|
| ReferenceEquals
| Boolean ReferenceEquals(System.Object, System.Object)
|
| ToString
| System.String ToString()
API元件:
https://drive.google.com/file/d/1OQXZIZAkwgum2f6QeTJMZluj3IacepoY/view?usp=sharing
希望高手幫幫忙XD