l_array = np.array([[0.0,0.0]])
quotes = [758529,3930881]
for i in quotes:
try:
v = [item["last_price"] for item in ticks if item['instrument_token'] == i]
a = v[0]
except:
continue
i_array = np.array[[instrument_token,a]]
l_array = np.append(i_array)
print(l_array)
[[0.000000e+00 0.000000e+00]
[7.58529e+06 11.487000e+01]
[3.930881e+06 9.985000e+01]]
Here ticks is a list class object(API Callback function output) that has to be converted to a numpy array(array within an array) to be saved as a.npy file, I can't seem to do this as the output ie l_array gives me a numpy array of complex numbers. The output must be a float numpy array.
you can try l_array.astype(float)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.